Loading [MathJax]/extensions/TeX/AMSmath.js
LALInference 4.1.9.1-00ddc7f
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALInferenceInitCBC.c
Go to the documentation of this file.
1/*
2 * LALInferenceCBCInit.c: Bayesian Followup initialisation routines.
3 *
4 * Copyright (C) 2012 Vivien Raymond, John Veitch, Salvatore Vitale
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with with program; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 * MA 02110-1301 USA
20 */
21
22
23#include <stdio.h>
24#include <errno.h>
25#include <lal/Date.h>
26#include <lal/GenerateInspiral.h>
27#include <lal/LALInference.h>
28#include <lal/FrequencySeries.h>
29#include <lal/Units.h>
30#include <lal/StringInput.h>
31#include <lal/LIGOLwXMLRead.h>
32#include <lal/TimeSeries.h>
33#include <lal/LALInferencePrior.h>
34#include <lal/LALInferenceTemplate.h>
35#include <lal/LALInferenceProposal.h>
36#include <lal/LALInferenceLikelihood.h>
37#include <lal/LALInferenceReadData.h>
38#include <lal/LALInferenceInit.h>
39#include <lal/LALInferenceCalibrationErrors.h>
40#include <lal/LALSimNeutronStar.h>
41
42static int checkParamInList(const char *list, const char *param);
43static int checkParamInList(const char *list, const char *param)
44{
45 /* Check for param in comma-seperated list */
46 char *post=NULL,*pos=NULL;
47 if (list==NULL) return 0;
48 if (param==NULL) return 0;
49
50 if(!(pos=strstr(list,param))) return 0;
51
52 /* The string is a substring. Check that it is a token */
53 /* Check the character before and after */
54 if(pos!=list)
55 if(*(pos-1)!=',')
56 return 0;
57
58 post=&(pos[strlen(param)]);
59 if(*post!='\0')
60 if(*post!=',')
61 return 0;
62 return 1;
63}
64
70
71
72/* Initialize a bare-bones run-state,
73 calling the "ReadData()" function to gather data & PSD from files,
74 sets up the random seed and rng, and initializes other variables accordingly.
75*/
78 INT4 randomseed;
79 FILE *devrandom;
80 struct timeval tv;
82
83 /* Check that command line is consistent first */
85 run_state->commandLine = command_line;
86
87 /* Initialize parameters structure */
88 run_state->algorithmParams = XLALCalloc(1, sizeof(LALInferenceVariables));
89 run_state->priorArgs = XLALCalloc(1, sizeof(LALInferenceVariables));
90 run_state->proposalArgs = XLALCalloc(1, sizeof(LALInferenceVariables));
91
92 /* Read data from files or generate fake data */
93 run_state->data = LALInferenceReadData(command_line);
94 if (run_state->data == NULL)
95 return(NULL);
96
97 /* Setup the random number generator */
98 gsl_rng_env_setup();
99 run_state->GSLrandom = gsl_rng_alloc(gsl_rng_mt19937);
100
101 /* Use clocktime if seed isn't provided */
102 ppt = LALInferenceGetProcParamVal(command_line, "--randomseed");
103 if (ppt)
104 randomseed = atoi(ppt->value);
105 else {
106 if ((devrandom = fopen("/dev/urandom","r")) == NULL) {
107 gettimeofday(&tv, 0);
108 randomseed = tv.tv_sec + tv.tv_usec;
109 } else {
110 fread(&randomseed, sizeof(randomseed), 1, devrandom);
111 fclose(devrandom);
112 }
113 }
114 gsl_rng_set(run_state->GSLrandom, randomseed);
115
116 /* Save the random seed */
117 LALInferenceAddVariable(run_state->algorithmParams, "random_seed", &randomseed,
119
120 return(run_state);
121}
122
123/* Draw initial parameters for each of the threads in run state */
125 if (run_state == NULL)
126 return;
127
128 if (run_state->threads == NULL) {
129 XLALPrintError("Error: LALInferenceDrawThreads expects initialized run_state->threads\n");
131 }
132
133 LALInferenceThreadState *thread = &(run_state->threads[0]);
134 INT4 t;
135
136 /* If using a malmquist prior, force a strict prior window on distance for starting point, otherwise
137 * the approximate prior draws are very unlikely to be within the malmquist prior */
138 REAL8 dist_low, dist_high;
139 REAL8 restricted_dist_low = log(10.0);
140 REAL8 restricted_dist_high = log(100.0);
141 INT4 changed_dist = 0;
142 if (LALInferenceCheckVariable(run_state->priorArgs, "malmquist") &&
143 LALInferenceCheckVariableNonFixed(thread->currentParams, "logdistance")) {
144 changed_dist = 1;
145 LALInferenceGetMinMaxPrior(run_state->priorArgs, "logdistance", &dist_low, &dist_high);
146 LALInferenceRemoveMinMaxPrior(run_state->priorArgs, "logdistance");
147 LALInferenceAddMinMaxPrior(run_state->priorArgs, "logdistance",
148 &restricted_dist_low, &restricted_dist_high, LALINFERENCE_REAL8_t);
149 }
150
151 /* If the currentParams are not in the prior, overwrite and pick paramaters
152 * from the priors. OVERWRITE EVEN USER CHOICES.
153 * (necessary for complicated prior shapes where
154 * LALInferenceCyclicReflectiveBound() is not enough) */
155 #pragma omp parallel for private(thread)
156 for (t = 0; t < run_state->nthreads; t++) {
158
159 thread = &(run_state->threads[t]);
160
161 /* Try not to clobber values given on the command line */
162 LALInferenceCopyVariables(thread->currentParams, priorDraw);
163 LALInferenceDrawApproxPrior(thread, priorDraw, priorDraw);
165 run_state->commandLine);
166
167 while(isinf(run_state->prior(run_state,
168 thread->currentParams,
169 thread->model))) {
171 thread->currentParams,
172 thread->currentParams);
173 }
174
175 /* Make sure that our initial value is within the
176 * prior-supported volume. */
178
179 /* Initialize starting likelihood and prior */
180 thread->currentPrior = run_state->prior(run_state,
181 thread->currentParams,
182 thread->model);
183
184 thread->currentLikelihood = run_state->likelihood(thread->currentParams,
185 run_state->data,
186 thread->model);
187
189 XLALFree(priorDraw);
190 }
191
192 /* Replace distance prior if changed for initial sample draw */
193 if (changed_dist) {
194 LALInferenceRemoveMinMaxPrior(run_state->priorArgs, "logdistance");
195 LALInferenceAddMinMaxPrior(run_state->priorArgs, "logdistance",
196 &dist_low, &dist_high, LALINFERENCE_REAL8_t);
197 }
198}
199
200/*
201 * Initialize threads in memory, using LALInferenceInitCBCModel() to init models.
202 */
204 if (run_state == NULL){
205 LALInferenceInitCBCModel(run_state);
206 return;
207 }
208
209 ProcessParamsTable *commandLine=run_state->commandLine;
210
212 INT4 t, nifo;
213 INT4 randomseed;
215 run_state->nthreads = nthreads;
216 run_state->threads = LALInferenceInitThreads(nthreads);
217
218 for (t = 0; t < nthreads; t++) {
219 thread = &(run_state->threads[t]);
220
221 /* Link back to run-state */
222 thread->parent = run_state;
223
224 /* Set up CBC model and parameter array */
225 thread->model = LALInferenceInitCBCModel(run_state);
226 thread->model->roq_flag = 0;
227
228 /* Allocate IFO likelihood holders */
229 nifo = 0;
230 data = run_state->data;
231 while (data != NULL) {
232 data = data->next;
233 nifo++;
234 }
235 thread->currentIFOLikelihoods = XLALCalloc(nifo, sizeof(REAL8));
236
237 /* Setup ROQ */
238 if (LALInferenceGetProcParamVal(commandLine, "--roqtime_steps")){
239
240 LALInferenceSetupROQmodel(thread->model, commandLine);
241 fprintf(stderr, "done LALInferenceSetupROQmodel\n");
242
243 }else{
244 thread->model->roq_flag=0;
245 }
246
249
250 /* Link thread-state prior-args to the parent run-state's */
251 thread->priorArgs = run_state->priorArgs;
252
253 /* Use clocktime if seed isn't provided */
254 thread->GSLrandom = gsl_rng_alloc(gsl_rng_mt19937);
255 randomseed = gsl_rng_get(run_state->GSLrandom);
256 gsl_rng_set(thread->GSLrandom, randomseed);
257 }
258
259 return;
260}
261
262
263/* Setup the template generation */
264/* Defaults to using LALSimulation */
266{
267 char help[]="(--template [LAL,PhenSpin,LALGenerateInspiral,LALSim,multiband]\tSpecify template (default LAL)\n";
269 ProcessParamsTable *commandLine=runState->commandLine;
270 /* Print command line arguments if help requested */
271 //Help is taken care of in LALInferenceInitCBCVariables
272 //ppt=LALInferenceGetProcParamVal(commandLine,"--help");
273 //if(ppt)
274 //{
275 // fprintf(stdout,"%s",help);
276 // return;
277 //}
278 /* This is the LAL template generator for inspiral signals */
280 ppt=LALInferenceGetProcParamVal(commandLine,"--template");
281 if(ppt) {
282 if(!strcmp("LALSim",ppt->value))
284 else if(!strcmp("null",ppt->value))
286 else if(!strcmp("multiband",ppt->value)){
288 fprintf(stdout,"Template function called is \"LALInferenceTemplateXLALSimInspiralChooseWaveformPhaseInterpolated\"\n");
289 }
290 else {
291 XLALPrintError("Error: unknown template %s\n",ppt->value);
292 XLALPrintError("%s", help);
294 }
295 }
296 else if(LALInferenceGetProcParamVal(commandLine,"--LALSimulation")){
297 fprintf(stderr,"Warning: --LALSimulation is deprecated, the LALSimulation package is now the default. To use LALInspiral specify:\n\
298 --template LALGenerateInspiral (for time-domain templates)\n\
299 --template LAL (for frequency-domain templates)\n");
300 }
301 else if(LALInferenceGetProcParamVal(commandLine,"--roqtime_steps")){
303 fprintf(stderr, "template is \"LALInferenceROQWrapperForXLALSimInspiralChooseFDWaveformSequence\"\n");
304 }
305 else {
306 fprintf(stdout,"Template function called is \"LALInferenceTemplateXLALSimInspiralChooseWaveform\"\n");
307 }
308 return templt;
309}
310
311/* Setup the glitch model */
313{
314 ProcessParamsTable *commandLine = runState->commandLine;
315 LALInferenceIFOData *dataPtr = runState->data;
316 LALInferenceVariables *priorArgs = runState->priorArgs;
317
318 UINT4 i,nifo;
319 UINT4 n = (UINT4)dataPtr->timeData->data->length;
320 UINT4 gflag = 1;
321 REAL8 gmin = 0.0;
322 REAL8 gmax = 20.0;
323
324 //over-ride default gmax from command line
325 if(LALInferenceGetProcParamVal(commandLine, "--glitchNmax"))
326 gmax = (REAL8)atoi(LALInferenceGetProcParamVal(commandLine, "--glitchNmax")->value);
327
328 //count interferometers in network before allocating memory
329 //compute imin,imax for each IFO -- may be different
330 nifo=0;
331 dataPtr = runState->data;
332 while (dataPtr != NULL)
333 {
334 dataPtr = dataPtr->next;
335 nifo++;
336 }
337 dataPtr = runState->data;
338
339 UINT4Vector *gsize = XLALCreateUINT4Vector(nifo);
340 //Meyer?? REAL8Vector *gprior = XLALCreateREAL8Vector((int)gmax+1);
341
342 //Morlet??
343 gsl_matrix *mAmp = gsl_matrix_alloc(nifo,(int)(gmax));
344 gsl_matrix *mf0 = gsl_matrix_alloc(nifo,(int)(gmax));
345 gsl_matrix *mQ = gsl_matrix_alloc(nifo,(int)(gmax));
346 gsl_matrix *mt0 = gsl_matrix_alloc(nifo,(int)(gmax));
347 gsl_matrix *mphi = gsl_matrix_alloc(nifo,(int)(gmax));
348
349 double Amin,Amax;
350 double Qmin,Qmax;
351 double f_min,f_max;
352 double tmin,tmax;
353 double pmin,pmax;
354 double Anorm;
355
356 REAL8 TwoDeltaToverN = 2.0 * dataPtr->timeData->deltaT / ((double) dataPtr->timeData->data->length);
357
358 Anorm = sqrt(TwoDeltaToverN);
359 Amin = 10.0/Anorm;
360 Amax = 10000.0/Anorm;
361
362 Qmin = 3.0;
363 Qmax = 30.0;
364 tmin = 0.0;
365 tmax = dataPtr->timeData->data->length*dataPtr->timeData->deltaT;
366 f_min = dataPtr->fLow;
367 f_max = dataPtr->fHigh;
368 pmin = 0.0;
369 pmax = LAL_TWOPI;
370
371 gsl_matrix_set_all(mAmp, Amin);
372 gsl_matrix_set_all(mf0, f_min);
373 gsl_matrix_set_all(mQ, Qmin);
374 gsl_matrix_set_all(mt0, tmin);
375 gsl_matrix_set_all(mphi, pmin);
376
377 gsl_matrix *gFD = gsl_matrix_alloc(nifo,(int)n); //store the Fourier-domain glitch signal
378
379 for(i=0; i<nifo; i++) gsize->data[i]=0;
380
381 //Morlet wavelet parameters
388
391
392 LALInferenceAddMinMaxPrior(priorArgs, "morlet_Amp_prior", &Amin, &Amax, LALINFERENCE_REAL8_t);
393 LALInferenceAddMinMaxPrior(priorArgs, "morlet_f0_prior" , &f_min, &f_max, LALINFERENCE_REAL8_t);
394 LALInferenceAddMinMaxPrior(priorArgs, "morlet_Q_prior" , &Qmin, &Qmax, LALINFERENCE_REAL8_t);
395 LALInferenceAddMinMaxPrior(priorArgs, "morlet_t0_prior" , &tmin, &tmax, LALINFERENCE_REAL8_t);
396 LALInferenceAddMinMaxPrior(priorArgs, "morlet_phi_prior", &pmin, &pmax, LALINFERENCE_REAL8_t);
397
398 LALInferenceAddMinMaxPrior(priorArgs, "glitch_size", &gmin, &gmax, LALINFERENCE_REAL8_t);
399 LALInferenceAddMinMaxPrior(priorArgs, "glitch_dim", &gmin, &gmax, LALINFERENCE_REAL8_t);
400
402}
403
405{
406 gsl_spline *amp_median,*amp_std,
409};
410
411/* Format string for the calibratino envelope file */
412/* Frequency Median Mag Phase (Rad) -1 Sigma Mag -1 Sigma Phase +1 Sigma Mag +1 Sigma Phase */
413
414#define CAL_ENV_FORMAT "%lf %lf %lf %lf %lf %lf %lf\n"
415
417
419{
420 FILE *fp=fopen(filename,"r");
421 char tmpline[1024];
422 if(!fp) {fprintf(stderr,"Unable to open %s: Error %i %s\n",filename,errno,strerror(errno)); exit(1);}
423 int Nlines=0;
424 REAL8 freq, *logfreq=NULL, *mag_med=NULL, mag_low, mag_hi, *mag_std=NULL, *phase_med=NULL, phase_low, phase_hi, *phase_std=NULL;
425 for(Nlines=0;fgets(tmpline,1024,fp); )
426 {
427 /* Skip header */
428 if(tmpline[0]=='#') continue;
429 /* Grow arrays */
430 logfreq=realloc(logfreq,sizeof(*logfreq)*(Nlines+1));
431 mag_med=realloc(mag_med,sizeof(*mag_med)*(Nlines+1));
432 mag_std=realloc(mag_std,sizeof(*mag_std)*(Nlines+1));
433 phase_med=realloc(phase_med,sizeof(*phase_med)*(Nlines+1));
434 phase_std=realloc(phase_std,sizeof(*phase_std)*(Nlines+1));
435
436 if((7!=sscanf(tmpline,CAL_ENV_FORMAT, &freq, &(mag_med[Nlines]), &(phase_med[Nlines]), &mag_low, &phase_low, &mag_hi, &phase_hi)))
437 {
438 fprintf(stderr,"Malformed input line in file %s: %s\n",filename,tmpline);
439 exit(1);
440 }
441 mag_med[Nlines]-=1.0; /* Subtract off 1 to get delta */
442 logfreq[Nlines]=log(freq);
443 mag_std[Nlines]=(mag_hi - mag_low ) /2.0;
444 phase_std[Nlines]=(phase_hi - phase_low) /2.0;
445 Nlines++;
446 }
447 fprintf(stdout,"Read %i lines from calibration envelope %s\n",Nlines,filename);
448 fclose(fp);
449
450 struct spcal_envelope *env=XLALCalloc(1,sizeof(*env));
451 env->amp_median = gsl_spline_alloc ( gsl_interp_cspline, Nlines);
452 env->amp_std = gsl_spline_alloc ( gsl_interp_cspline, Nlines);
453 env->phase_median = gsl_spline_alloc ( gsl_interp_cspline, Nlines);
454 env->phase_std = gsl_spline_alloc ( gsl_interp_cspline, Nlines);
455
456 gsl_spline_init(env->amp_median, logfreq, mag_med, Nlines);
457 gsl_spline_init(env->amp_std, logfreq, mag_std, Nlines);
458 gsl_spline_init(env->phase_median, logfreq, phase_med, Nlines);
459 gsl_spline_init(env->phase_std, logfreq, phase_std, Nlines);
460 env->logf_min = logfreq[0];
461 env->logf_max = logfreq[Nlines-1];
462
463 free(logfreq); free(mag_med); free(mag_std); free(phase_med); free(phase_std);
464
465 return(env);
466}
467
468static int destroyCalibrationEnvelope(struct spcal_envelope *env);
470{
471 if(!env) XLAL_ERROR(XLAL_EINVAL);
472 if(env->amp_median) gsl_spline_free(env->amp_median);
473 if(env->amp_std) gsl_spline_free(env->amp_std);
474 if(env->phase_median) gsl_spline_free(env->phase_median);
475 if(env->phase_std) gsl_spline_free(env->phase_std);
476 XLALFree(env);
477 return XLAL_SUCCESS;
478}
479
481 ProcessParamsTable *ppt = NULL;
482 LALInferenceIFOData *ifo = NULL;
483 LALInferenceIFOData *dataPtr=NULL;
484 UINT4 calOn = 1;
485 if ((ppt = LALInferenceGetProcParamVal(runState->commandLine, "--enable-spline-calibration"))){
486 /* Use spline to marginalize*/
487 UINT4 ncal = 5; /* Number of calibration nodes, log-distributed
488 between fmin and fmax. */
489 REAL8 ampUncertaintyPrior = 0.1; /* 10% amplitude */
490 REAL8 phaseUncertaintyPrior = 5*M_PI/180.0; /* 5 degrees phase */
491 if ((ppt = LALInferenceGetProcParamVal(runState->commandLine, "--spcal-nodes"))) {
492 ncal = atoi(ppt->value);
493 if (ncal < 3) { /* Cannot do spline with fewer than 3 points! */
494 fprintf(stderr, "ERROR: given '--spcal-nodes %d', but cannot spline with fewer than 3\n", ncal);
495 exit(1);
496 }
497 }
498
501
502 for(ifo=runState->data;ifo;ifo=ifo->next) {
503 UINT4 i;
504
505 char freqVarName[VARNAME_MAX];
506 char ampVarName[VARNAME_MAX];
507 char phaseVarName[VARNAME_MAX];
508
509 REAL8 fMin = ifo->fLow;
510 REAL8 fMax = ifo->fHigh;
511 REAL8 logFMin = log(fMin);
512 REAL8 logFMax = log(fMax);
513
514 char amp_uncert_op[VARNAME_MAX];
515 char pha_uncert_op[VARNAME_MAX];
516 char env_uncert_op[VARNAME_MAX];
517 struct spcal_envelope *env=NULL;
518
519 if((VARNAME_MAX <= snprintf(amp_uncert_op, VARNAME_MAX, "--%s-spcal-amp-uncertainty", ifo->name))
520 || (VARNAME_MAX <= snprintf(pha_uncert_op, VARNAME_MAX, "--%s-spcal-phase-uncertainty", ifo->name))
521 || (VARNAME_MAX <= snprintf(env_uncert_op, VARNAME_MAX, "--%s-spcal-envelope",ifo->name)) )
522 {
523 fprintf(stderr,"variable name too long\n"); exit(1);
524 }
525
526 if( (ppt=LALInferenceGetProcParamVal(runState->commandLine, env_uncert_op)))
527 {
529 /* If the spline limits are within the data frequency bounds, update the bounds */
530 logFMin = env->logf_min>logFMin ? env->logf_min : logFMin;
531 logFMax = env->logf_max<logFMax ? env->logf_max : logFMax;
532 }
533 else
534 {
535 if ((ppt = LALInferenceGetProcParamVal(runState->commandLine, amp_uncert_op))) {
536 ampUncertaintyPrior = atof(ppt->value);
537 }
538 else{
539 fprintf(stderr,"Error, missing %s or %s\n",amp_uncert_op, env_uncert_op);
540 exit(1);
541 }
542
543 if ((ppt = LALInferenceGetProcParamVal(runState->commandLine, pha_uncert_op))) {
544 phaseUncertaintyPrior = M_PI/180.0*atof(ppt->value); /* CL arg in degrees, variable in radians */
545 }
546 else{
547 fprintf(stderr,"Error, missing %s or %s\n",pha_uncert_op,env_uncert_op);
548 exit(1);
549 }
550 }
551 REAL8 dLogF = (logFMax - logFMin)/(ncal-1);
552 /* Now add each spline node */
553 for(i=0;i<ncal;i++)
554 {
555 if((VARNAME_MAX <= snprintf(freqVarName, VARNAME_MAX, "%s_spcal_logfreq_%i",ifo->name,i))
556 || (VARNAME_MAX <= snprintf(ampVarName, VARNAME_MAX, "%s_spcal_amp_%i", ifo->name,i))
557 || (VARNAME_MAX <= snprintf(phaseVarName, VARNAME_MAX, "%s_spcal_phase_%i", ifo->name,i)) )
558 {
559 fprintf(stderr,"Variable name too long\n"); exit(1);
560 }
561 REAL8 amp_std=ampUncertaintyPrior,amp_mean=0.0;
562 REAL8 phase_std=phaseUncertaintyPrior,phase_mean=0.0;
563 REAL8 logFreq = logFMin + i*dLogF;
565 if(env)
566 {
567 amp_std = gsl_spline_eval(env->amp_std, logFreq, NULL);
568 amp_mean = gsl_spline_eval(env->amp_median, logFreq, NULL);
569 phase_std = gsl_spline_eval(env->phase_std, logFreq, NULL);
570 phase_mean = gsl_spline_eval(env->phase_median, logFreq, NULL);
571 }
574 } /* End loop over spline nodes */
575
576 if(env) destroyCalibrationEnvelope(env);
577 } /* End loop over IFOs */
578 } /* End case of spline calibration error */
579 else if(LALInferenceGetProcParamVal(runState->commandLine, "--MarginalizeConstantCalAmp") ||LALInferenceGetProcParamVal(runState->commandLine, "--MarginalizeConstantCalPha")){
580 /* Use constant (in frequency) approximation for the errors */
581 if (LALInferenceGetProcParamVal(runState->commandLine, "--MarginalizeConstantCalAmp")){
582 /*For the moment the prior ranges are the same for the three IFOs */
583 REAL8 camp_max_A=0.25; /* plus minus 25% amplitude errors*/
584 REAL8 camp_min_A=-0.25;
585 REAL8 zero=0.0;
586 dataPtr = runState->data;
587 while (dataPtr != NULL){
588 char CA_A[320];
589 sprintf(CA_A,"%s_%s","calamp",dataPtr->name);
590 LALInferenceRegisterUniformVariableREAL8(runState, currentParams, CA_A, zero, camp_min_A, camp_max_A, LALINFERENCE_PARAM_LINEAR);
591 dataPtr = dataPtr->next;
592 }
593
595 /*If user specifies a width for the error prior, a gaussian prior will be used, otherwise a flat prior will be used*/
596 REAL8 ampUncertaintyPrior=-1.0;
597 ppt = LALInferenceGetProcParamVal(runState->commandLine, "--constcal_ampsigma");
598 if (ppt) {
599 ampUncertaintyPrior = atof(ppt->value);
600 }
601 LALInferenceAddVariable(runState->priorArgs, "constcal_amp_uncertainty", &ampUncertaintyPrior, LALINFERENCE_REAL8_t, LALINFERENCE_PARAM_FIXED);
602 }
603 if (LALInferenceGetProcParamVal(runState->commandLine, "--MarginalizeConstantCalPha")){
604 /* Add linear calibration phase errors to the measurement. For the moment the prior ranges are the same for the three IFOs */
605 REAL8 cpha_max_A=0.349; /* plus/minus 20 degs*/
606 REAL8 cpha_min_A=-0.349;
607 REAL8 zero=0.0;
608 dataPtr = runState->data;
609 while (dataPtr != NULL)
610 {
611 char CP_A[320];
612 sprintf(CP_A,"%s_%s","calpha",dataPtr->name);
613 LALInferenceRegisterUniformVariableREAL8(runState, currentParams, CP_A, zero, cpha_min_A, cpha_max_A, LALINFERENCE_PARAM_LINEAR);
614 dataPtr = dataPtr->next;
615 }
617
618 /*If user specifies a width for the error prior, a gaussian prior will be used, otherwise a flat prior will be used*/
619 REAL8 phaseUncertaintyPrior=-1.0;
620 ppt = LALInferenceGetProcParamVal(runState->commandLine, "--constcal_phasigma");
621 if (ppt) {
622 phaseUncertaintyPrior = M_PI/180.0*atof(ppt->value); /* CL arg in degrees, variable in radians */
623 }
624 LALInferenceAddVariable(runState->priorArgs, "constcal_phase_uncertainty", &phaseUncertaintyPrior, LALINFERENCE_REAL8_t, LALINFERENCE_PARAM_FIXED);
625
626 }
627 }
628 else{
629 /* No calibration marginalization asked. Just exit */
630 return;
631 }
632}
633
635{
636 char meanopt[VARNAME_MAX+8];
637 char sigmaopt[VARNAME_MAX+9];
638 char valopt[VARNAME_MAX+3];
639 char fixopt[VARNAME_MAX+7];
641
642 sprintf(meanopt,"--%s-mean",name);
643 sprintf(sigmaopt,"--%s-sigma",name);
644 sprintf(valopt,"--%s",name);
645 sprintf(fixopt,"--fix-%s",name);
646
647 if((ppt=LALInferenceGetProcParamVal(state->commandLine,meanopt))) mean=atof(ppt->value);
648 if((ppt=LALInferenceGetProcParamVal(state->commandLine,sigmaopt))) stdev=atof(ppt->value);
649 if((ppt=LALInferenceGetProcParamVal(state->commandLine,fixopt)))
650 {
651 varytype = LALINFERENCE_PARAM_FIXED;
652 startval = atof(ppt->value);
653 }
654 if((ppt=LALInferenceGetProcParamVal(state->commandLine,valopt))) startval=atof(ppt->value);
655
656 XLAL_CHECK_ABORT(stdev>0);
657 LALInferenceAddVariable(var,name,&startval,LALINFERENCE_REAL8_t,varytype);
659
660}
661
663{
664 char minopt[VARNAME_MAX+7];
665 char maxopt[VARNAME_MAX+7];
666 char valopt[VARNAME_MAX+3];
667 char fixopt[VARNAME_MAX+7];
669
670 sprintf(minopt,"--%s-min",name);
671 sprintf(maxopt,"--%s-max",name);
672 sprintf(valopt,"--%s",name);
673 sprintf(fixopt,"--fix-%s",name);
674
675 if((ppt=LALInferenceGetProcParamVal(state->commandLine,minopt))) min=atof(ppt->value);
676 if((ppt=LALInferenceGetProcParamVal(state->commandLine,maxopt))) max=atof(ppt->value);
677 if((ppt=LALInferenceGetProcParamVal(state->commandLine,fixopt))) {
679 startval=atof(ppt->value);
680 }
681 if((ppt=LALInferenceGetProcParamVal(state->commandLine,valopt))) startval=atof(ppt->value);
682 else if(varytype!=LALINFERENCE_PARAM_FIXED) startval=min+(max-min)*gsl_rng_uniform(state->GSLrandom);
683
684 /* Error checking */
685 if(min>max) {
686 fprintf(stderr,"ERROR: Prior for %s has min(%lf) > max(%lf)\n",name,min,max);
687 exit(1);
688 }
689 if(startval<min || startval>max){
690 fprintf(stderr,"ERROR: Initial value %lf for %s lies outwith prior (%lf,%lf)\n",startval,name,min,max);
691 exit(1);
692 }
693 /* Mass parameters checks*/
694 if (!strcmp(name,"eta"))
695 if (max>0.25){
696 fprintf(stderr,"ERROR: maximum of eta cannot be larger than 0.25. Check --eta-max\n");
697 exit(1);
698 }
699 if (!strcmp(name,"q")){
700 REAL8 qMin=min;
701 REAL8 qMax=max;
702
703 if (qMin <= 0.0 || qMin > 1.0)
704 {
705 fprintf(stderr,"ERROR: qMin must be between 0 and 1, got value qMin=%f\n",qMin);
706 exit(1);
707 }
708 if (qMax > 1.0 || qMax <0.0 || qMax < qMin)
709 {
710 fprintf(stderr,"ERROR: qMax must be between 0 and 1, and qMax > qMin. Got value qMax=%f, qMin=%f\n",qMax,qMin);
711 exit(1);
712 }
713 }
714 /*End of mass parameters check */
715
716 LALInferenceAddVariable(var,name,&startval,LALINFERENCE_REAL8_t,varytype);
718
719}
720
721
722/* Setup the variables to control template generation for the CBC model */
723/* Includes specification of prior ranges. Returns address of new LALInferenceVariables */
724
726 char help[]="\
727 ----------------------------------------------\n\
728 --- Injection Arguments ----------------------\n\
729 ----------------------------------------------\n\
730 (--inj injections.xml) Injection XML file to use\n\
731 (--event N) Event number from Injection XML file to use\n\
732\n\
733 ----------------------------------------------\n\
734 --- Template Arguments -----------------------\n\
735 ----------------------------------------------\n\
736 (--use-eta) Jump in symmetric mass ratio eta, instead of q=m1/m2 (m1>m2)\n\
737 (--approx) Specify a template approximant and phase order to use\n\
738 (default TaylorF2threePointFivePN). Available approximants:\n\
739 default modeldomain=\"time\": GeneratePPN, TaylorT1, TaylorT2,\n\
740 TaylorT3, TaylorT4, EOB, EOBNR,\n\
741 EOBNRv2, EOBNRv2HM, SEOBNRv1,\n\
742 SpinTaylor, SpinQuadTaylor, \n\
743 SpinTaylorFrameless, SpinTaylorT4,\n\
744 PhenSpinTaylorRD, NumRel.\n\
745 default modeldomain=\"frequency\": TaylorF1, TaylorF2, TaylorF2RedSpin,\n\
746 TaylorF2RedSpinTidal, IMRPhenomA,\n\
747 IMRPhenomB, IMRPhenomP, IMRPhenomPv2.\n\
748 (--amporder PNorder) Specify a PN order in amplitude to use (defaults: LALSimulation: max available; LALInspiral: newtownian).\n\
749 (--fref f_ref) Specify a reference frequency at which parameters are defined (default 100).\n\
750 (--tidal) Enables tidal corrections, only with LALSimulation.\n\
751 (--tidalT) Enables reparmeterized tidal corrections, only with LALSimulation.\n\
752 (--4PolyEOS) Enables 4-piece polytropic EOS parmeterization, only with LALSimulation.\n\
753 (--4SpectralDecomp) Enables 4-coeff. spectral decomposition EOS parmeterization, only with LALSimulation.\n\
754 (--eos EOS) Fix the neutron star EOS. Use \"--eos help\" for allowed names\n\
755 (--BinaryLove) Enable the Binary Neutron Star common EoS tidal model, expressed through EOS-insensitive relations\n\
756 (--spinOrder PNorder) Specify twice the PN order (e.g. 5 <==> 2.5PN) of spin effects to use, only for LALSimulation (default: -1 <==> Use all spin effects).\n\
757 (--tidalOrder PNorder) Specify twice the PN order (e.g. 10 <==> 5PN) of tidal effects to use, only for LALSimulation (default: -1 <==> Use all tidal effects).\n\
758 (--numreldata FileName) Location of NR data file for NR waveforms (with NR_hdf5 approx).\n\
759 (--modeldomain) domain the waveform template will be computed in (\"time\" or \"frequency\"). If not given will use LALSim to decide\n\
760 (--spinAligned or --aligned-spin) template will assume spins aligned with the orbital angular momentum.\n\
761 (--singleSpin) template will assume only the spin of the most massive binary component exists.\n\
762 (--noSpin, --disable-spin) template will assume no spins (giving this will void spinOrder!=0) \n\
763 (--no-detector-frame) model will NOT use detector-centred coordinates and instead RA,dec\n\
764 (--nonGR_alpha value) this is a LIV parameter which should only be passed when log10lambda_eff/lambda_eff is passed as a grtest-parameter for LIV test\n\
765 (--LIV_A_sign) this is a LIV parameter determining if +A or -A is being tested; A occurs in the modified dispersion relation. LIV_A_sign has to be either +1 or -1 \n\
766 (--liv) this flag is now needed for launching a LIV run\n\
767 (--grtest-parameters dchi0,..,dxi1,..,dalpha1,..) template will assume deformations in the corresponding phase coefficients.\n\
768 (--generic-fd-correction) enables the generic frequency domain corrections to the template phase. \n\
769 (--generic-fd-correction-hm) apply generic frequency domain corrections to higher-modes waveform. \n\
770 (--generic-fd-correction-window) sets the fraction of the peak frequency up to which the generic phase corrections are applied (default=1). \n\
771 (--generic-fd-correction-ncycles) sets the number of cycles for the tapering of the generic phase corrections (default=1). \n\
772 (--ppe-parameters aPPE1,.... template will assume the presence of an arbitrary number of PPE parameters. They must be paired correctly.\n\
773 (--modeList lm,l-m...,lm,l-m) List of modes to be used by the model. The chosen modes ('lm') should be passed as a ',' seperated list.\n\
774 (--phenomXHMMband float) Threshold parameter for the Multibanding of the non-precessing hlm modes in IMRPhenomXHM and IMRPhenomXPHM. If set to 0 then do not use multibanding.\n\
775 Options and default values can be found in https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/group___l_a_l_sim_i_m_r_phenom_x__c.html\n\
776 (--phenomXPHMMband float) Threshold parameter for the Multibanding of the Euler angles in IMRPhenomXPHM. If set to 0 then do not use multibanding.\n\
777 Options and default values can be found in https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/group___l_a_l_sim_i_m_r_phenom_x__c.html\n\
778 (--phenomXPFinalSpinMod int) Change version for the final spin model used in IMRPhenomXP/IMRPhenomXPHM.\n\
779 Options and default values can be found in https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/group___l_a_l_sim_i_m_r_phenom_x__c.html\n\
780 (--phenomXPrecVersion int) Change version of the Euler angles for the twisting-up of IMRPhenomXP/IMRPhenomXPHM.\n\
781 Options and default values can be found in https://lscsoft.docs.ligo.org/lalsuite/lalsimulation/group___l_a_l_sim_i_m_r_phenom_x__c.html\n\
782\n\
783 ----------------------------------------------\n\
784 --- Starting Parameters ----------------------\n\
785 ----------------------------------------------\n\
786 You can generally have MCMC chains to start from a given parameter value by using --parname VALUE. Names currently known to the code are:\n\
787 time Waveform time (overrides random about trigtime).\n\
788 chirpmass Chirpmass\n\
789 eta Symmetric massratio (needs --use-eta)\n\
790 q Asymmetric massratio (a.k.a. q=m2/m1 with m1>m2)\n\
791 phase Coalescence phase.\n\
792 costheta_jn Cosine of angle between J and line of sight [rads]\n\
793 logdistance Log Distance (requires --use-logdistance)\n\
794 rightascension Rightascensions\n\
795 declination Declination.\n\
796 polarisation Polarisation angle.\n\
797 * Spin Parameters:\n\
798 a_spin1 Spin1 magnitude\n\
799 a_spin2 Spin2 magnitude\n\
800 tilt_spin1 Angle between spin1 and orbital angular momentum\n\
801 tilt_spin2 Angle between spin2 and orbital angular momentum \n\
802 phi_12 Difference between spins' azimuthal angles \n\
803 phi_jl Difference between total and orbital angular momentum azimuthal angles\n\
804 * Equation of State parameters:\n\
805 (requires --tidal)\n\
806 lambda1 lambda1.\n\
807 lambda2 lambda2.\n\
808 (requires --tidalT)\n\
809 lambdaT lambdaT.\n\
810 dLambdaT dLambdaT.\n\
811 (requires --4PolyEOS)\n\
812 logp1 logp1.\n\
813 gamma1 gamma1.\n\
814 gamma2 gamma2.\n\
815 gamma3 gamma3.\n\
816 (requires --BinaryLove)\n\
817 lambdaS Symmetric tidal deformability.\n\
818 (requires --4SpectralDecomp):\n\
819 SDgamma0 SDgamma0.\n\
820 SDgamma1 SDgamma1.\n\
821 SDgamma2 SDgamma2.\n\
822 SDgamma3 SDgamma3.\n\
823 * \n\
824 * Spin-induced quadrupole moment test parameters:\n\
825 (requires --dQuadMon12)\n\
826 dQuadMon1 dQuadMon1.\n\
827 dQuadMon2 dQuadMon2.\n\
828 (requires --dQuadMonSA) \n\
829 dQuadMonS dQuadMonS.\n\
830 dQuadMonA dQuadMonA.\n\
831 (dQuadMonS and dQuadMonA are the symmetric and antisymmetric combinations of dQuadMon1 and dQuadMon2).\n\
832 ----------------------------------------------\n\
833 --- Prior Ranges -----------------------------\n\
834 ----------------------------------------------\n\
835 You can generally use --paramname-min MIN --paramname-max MAX to set the prior range for the parameter paramname\n\
836 The names known to the code are listed below.\n\
837 Component masses, total mass and time have dedicated options listed here:\n\n\
838 (--trigtime time) Center of the prior for the time variable.\n\
839 (--comp-min min) Minimum component mass (1.0).\n\
840 (--comp-max max) Maximum component mass (100.0).\n\
841 (--mass1-min min, --mass1-max max) Min and max for mass1 (default: same as comp-min,comp-max, will over-ride these.\n\
842 (--mass2-min min, --mass2-max max) Min and max for mass2 (default: same as comp-min,comp-max, will over-ride these.\n\
843 (--mtotal-min min) Minimum total mass (2.0).\n\
844 (--mtotal-max max) Maximum total mass (200.0).\n\
845 (--dt time) Width of time prior, centred around trigger (0.2s).\n\
846\n\
847 (--ns-max-mass) Maximum observed NS mass used for EOS prior (none).\n\
848 (--varyFlow, --flowMin, --flowMax) Allow the lower frequency bound of integration to vary in given range.\n\
849 (--pinparams) List of parameters to set to injected values [mchirp,asym_massratio,etc].\n\
850 ----------------------------------------------\n\
851 --- Fix Parameters ---------------------------\n\
852 ----------------------------------------------\n\
853 You can generally fix a parameter to be fixed to a given values by using --fix-paramname VALUE\n\
854 where the known names have been listed above.\n\
855\n";
856
857 /* Print command line arguments if state was not allocated */
858 if(state==NULL)
859 {
860 fprintf(stdout,"%s",help);
861 return(NULL);
862 }
863
864 /* Print command line arguments if help requested */
865 if(LALInferenceGetProcParamVal(state->commandLine,"--help"))
866 {
867 fprintf(stdout,"%s",help);
868 return(NULL);
869 }
870
872 memset(&status,0,sizeof(status));
873 int errnum;
874 SimInspiralTable *injTable=NULL;
875 LALInferenceVariables *priorArgs=state->priorArgs;
876 LALInferenceVariables *proposalArgs=state->proposalArgs;
877 ProcessParamsTable *commandLine=state->commandLine;
879 ProcessParamsTable *ppt_order=NULL;
880 LALPNOrder PhaseOrder=-1;
881 LALPNOrder AmpOrder=-1;
883 REAL8 f_ref = 100.0;
884 LALInferenceIFOData *dataPtr;
885 UINT4 event=0;
886 UINT4 i=0;
887 /* Default priors */
888 REAL8 Dmin=1.0;
889 REAL8 Dmax=2000.0;
890 REAL8 Dinitial = (Dmax + Dmin)/2.0;
891 REAL8 mcMin=1.0;
892 REAL8 mcMax=15.3;
893 REAL8 etaMin=0.0312;
894 REAL8 etaMax=0.25;
895 REAL8 qMin=1./30.; // The ratio between min and max component mass (see InitMassVariables)
896 REAL8 qMax=1.0;
897 REAL8 psiMin=0.0,psiMax=LAL_PI;
898 REAL8 decMin=-LAL_PI/2.0,decMax=LAL_PI/2.0;
899 REAL8 raMin=0.0,raMax=LAL_TWOPI;
900 REAL8 phiMin=0.0,phiMax=LAL_TWOPI;
901 REAL8 costhetaJNmin=-1.0 , costhetaJNmax=1.0;
902 REAL8 dt=0.1; /* Half the width of time prior */
903 REAL8 lambda1Min=0.0;
904 REAL8 lambda1Max=3000.0;
905 REAL8 lambda2Min=0.0;
906 REAL8 lambda2Max=3000.0;
907 REAL8 lambdaTMin=0.0;
908 REAL8 lambdaTMax=3000.0;
909 REAL8 dLambdaTMin=-500.0;
910 REAL8 dLambdaTMax=500.0;
911 REAL8 dQuadMonMin=-200.0;
912 REAL8 dQuadMonMax=200.0;
913 REAL8 logp1Min=33.6;
914 REAL8 logp1Max=35.4;
915 REAL8 gamma1Min=2.0;
916 REAL8 gamma1Max=4.5;
917 REAL8 gamma2Min=1.1;
918 REAL8 gamma2Max=4.5;
919 REAL8 gamma3Min=1.1;
920 REAL8 gamma3Max=4.5;
921 REAL8 lambdaSMin=0.0;
922 REAL8 lambdaSMax=5000.0;
923 REAL8 SDgamma0Min=0.2;
924 REAL8 SDgamma0Max=2.0;
925 REAL8 SDgamma1Min=-1.6;
926 REAL8 SDgamma1Max=1.7;
927 REAL8 SDgamma2Min=-0.6;
928 REAL8 SDgamma2Max=0.6;
929 REAL8 SDgamma3Min=-0.02;
930 REAL8 SDgamma3Max=0.02;
931 gsl_rng *GSLrandom=state->GSLrandom;
932 REAL8 endtime=0.0, timeParam=0.0;
933 REAL8 timeMin=endtime-dt,timeMax=endtime+dt;
934 REAL8 zero=0.0; /* just a number that will be overwritten anyway*/
935
936 /* Over-ride prior bounds if analytic test */
937 if (LALInferenceGetProcParamVal(commandLine, "--correlatedGaussianLikelihood"))
938 {
940 }
941 else if (LALInferenceGetProcParamVal(commandLine, "--bimodalGaussianLikelihood"))
942 {
944 }
945 else if (LALInferenceGetProcParamVal(commandLine, "--rosenbrockLikelihood"))
946 {
947 return(LALInferenceInitModelReviewEvidence(state)); /* CHECKME: Use the default prior for unimodal */
948 }
949
951 model->params = XLALCalloc(1, sizeof(LALInferenceVariables));
952 memset(model->params, 0, sizeof(LALInferenceVariables));
953 model->eos_fam = NULL;
954
955 UINT4 signal_flag=1;
956 ppt = LALInferenceGetProcParamVal(commandLine, "--noiseonly");
957 if(ppt)signal_flag=0;
958 LALInferenceAddVariable(model->params, "signalModelFlag", &signal_flag, LALINFERENCE_INT4_t, LALINFERENCE_PARAM_FIXED);
959
960 /* Read injection XML file for parameters if specified */
961 ppt=LALInferenceGetProcParamVal(commandLine,"--inj");
962 if(ppt){
964 if(!injTable){
965 fprintf(stderr,"Unable to open injection file %s\n",ppt->value);
966 exit(1);
967 }
968 ppt=LALInferenceGetProcParamVal(commandLine,"--event");
969 if(ppt){
970 event= atoi(ppt->value);
971 fprintf(stderr,"Reading event %d from file\n",event);
972 i=0;
973 while(i<event) {i++; injTable=injTable->next;} /* select event */
974 }
975 }
976
977 /* See if there are any parameters pinned to injection values */
978 if((ppt=LALInferenceGetProcParamVal(commandLine,"--pinparams"))){
979 char *pinned_params=ppt->value;
980 LALInferenceVariables tempParams;
981 memset(&tempParams,0,sizeof(tempParams));
982 char **strings=NULL;
983 UINT4 N;
984 LALInferenceParseCharacterOptionString(pinned_params,&strings,&N);
985 LALInferenceInjectionToVariables(injTable,&tempParams);
986 LALInferenceVariableItem *node=NULL;
987 while(N>0){
988 N--;
989 char *name=strings[N];
990 fprintf(stdout,"Pinning parameter %s\n",name);
991 node=LALInferenceGetItem(&tempParams,name);
992 if(node) LALInferenceAddVariable(model->params,node->name,node->value,node->type,node->vary);
993 else {fprintf(stderr,"Error: Cannot pin parameter %s. No such parameter found in injection!\n",name);}
994 }
995 }
996
997 /* Over-ride approximant if user specifies */
998 ppt=LALInferenceGetProcParamVal(commandLine,"--approximant");
999 if(ppt){
1001 ppt_order=LALInferenceGetProcParamVal(commandLine,"--order");
1002 if(ppt_order) PhaseOrder = XLALGetOrderFromString(ppt_order->value);
1003 }
1004 ppt=LALInferenceGetProcParamVal(commandLine,"--approx");
1005 if(ppt){
1007 XLAL_TRY(PhaseOrder = XLALGetOrderFromString(ppt->value),errnum);
1008 if( (int) PhaseOrder == XLAL_FAILURE || errnum) {
1009 PhaseOrder=-1;
1010 }
1011 }
1012
1013 ppt=LALInferenceGetProcParamVal(commandLine,"--amporder");
1014 if(ppt) AmpOrder=atoi(ppt->value);
1015
1016 if(approx==NumApproximants && injTable){ /* Read aproximant from injection file */
1018 }
1020 approx=TaylorF2; /* Defaults to TF2 */
1021 XLALPrintWarning("You did not provide an approximant for the templates. Using default %s, which might now be what you want!\n",XLALSimInspiralGetStringFromApproximant(approx));
1022 }
1023
1024 /* Set the model domain appropriately */
1028 model->domain = LAL_SIM_DOMAIN_TIME;
1029 } else {
1030 fprintf(stderr,"ERROR. Unknown approximant number %i. Unable to choose time or frequency domain model.",approx);
1031 exit(1);
1032 }
1033
1034 ppt=LALInferenceGetProcParamVal(commandLine, "--fref");
1035 if (ppt) f_ref = atof(ppt->value);
1036
1037 ppt=LALInferenceGetProcParamVal(commandLine,"--modeldomain");
1038 if(ppt){
1039 if ( ! strcmp( "time", ppt->value ) )
1040 {
1041 model->domain = LAL_SIM_DOMAIN_TIME;
1042 }
1043 else if ( ! strcmp( "frequency", ppt->value ) )
1044 {
1046 }
1047 else
1048 {
1049 fprintf( stderr, "invalid argument to --modeldomain:\n"
1050 "unknown domain specified: "
1051 "domain must be one of: time, frequency\n");
1052 exit( 1 );
1053 }
1054 }
1055
1056 /* This sets the component masses and total mass priors, if given in command line.
1057 * The prior for other parameters are now read in in RegisterUniformVariable, if given by the user. */
1059 /* now we need to update the chirp mass and q limits accordingly */
1060 REAL8 m2_min=LALInferenceGetREAL8Variable(state->priorArgs,"mass2_min");
1061 REAL8 m1_max=LALInferenceGetREAL8Variable(state->priorArgs,"mass1_max");
1062 REAL8 mtot_min = *(REAL8 *)LALInferenceGetVariable(state->priorArgs,"MTotMin");
1063 REAL8 mtot_max = *(REAL8 *)LALInferenceGetVariable(state->priorArgs,"MTotMax");
1064 qMin = m2_min / m1_max;
1065 mcMin =mtot_min*pow(qMin/pow(1.+qMin,2.),3./5.);
1066 mcMax =mtot_max*pow(0.25,3./5.);
1067
1068 /************ Initial Value Related Argument START *************/
1069 /* Read time parameter from injection file */
1070 if(injTable)
1071 {
1072 endtime=XLALGPSGetREAL8(&(injTable->geocent_end_time));
1073 fprintf(stdout,"Using end time from injection file: %lf\n", endtime);
1074 }
1075 /* Over-ride end time if specified */
1076 ppt=LALInferenceGetProcParamVal(commandLine,"--trigtime");
1077 if(ppt){
1078 endtime=atof(ppt->value);
1079 printf("Read end time %f\n",endtime);
1080 }
1081 /* Over-ride time prior window if specified */
1082 ppt=LALInferenceGetProcParamVal(commandLine,"--dt");
1083 if(ppt)
1084 dt=atof(ppt->value);
1085 timeMin=endtime-dt; timeMax=endtime+dt;
1086 timeParam = timeMin + (timeMax-timeMin)*gsl_rng_uniform(GSLrandom);
1087
1088 /* Initial Value Related END */
1090 LALInferenceAddVariable(model->params, "LAL_PNORDER", &PhaseOrder, LALINFERENCE_INT4_t, LALINFERENCE_PARAM_FIXED);
1093
1094 /* Get frequency bounds */
1095 REAL8 fLow = INFINITY; // lowest frequency being analyzed across the network
1096 REAL8 fHigh = -INFINITY; // highest frequency being analyzed across the network
1097
1098 dataPtr = state->data;
1099 while (dataPtr != NULL)
1100 {
1101 if (dataPtr->fLow < fLow)
1102 fLow = dataPtr->fLow;
1103 if (dataPtr->fHigh > fHigh)
1104 fHigh = dataPtr->fHigh;
1105
1106 dataPtr = dataPtr->next;
1107 }
1108
1109 model->fLow = fLow;
1110 model->fHigh = fHigh;
1111
1112 /* Check if flow is varying */
1113 ppt=LALInferenceGetProcParamVal(commandLine,"--vary-flow");
1114 if(ppt){
1115 REAL8 fLow_min = fLow;
1116 REAL8 fLow_max = 200.0;
1117 if(LALInferenceCheckVariable(model->params,"f_ref"))
1118 f_ref = *(REAL8*)LALInferenceGetVariable(model->params, "f_ref");
1119 if (f_ref > 0.0 && fLow_max > f_ref) {
1120 fprintf(stdout,"WARNING: flow can't go higher than the reference frequency. Setting flow-max to %f\n",f_ref);
1121 fLow_max = f_ref;
1122 }
1123 LALInferenceRegisterUniformVariableREAL8(state, model->params, "flow", fLow, fLow_min, fLow_max, LALINFERENCE_PARAM_LINEAR);
1124 } else {
1126 }
1127 /* Set up the variable parameters */
1128
1129 /********************* TBL: Adding noise-fitting parameters *********************/
1130 UINT4 nscale_block; //number of noise parameters per IFO (1 per frequency block)
1131 UINT4 nscale_bin; //number of Fourier bins in each noise block
1132 REAL8 nscale_dflog; //logarithmic spacing for noise parameters
1133 REAL8 nscale_min; //minimum value for psd scale parameter
1134 REAL8 nscale_max; //maximum value for psd scale parameters
1135 UINT4 nscale_dim; //total dimension of noise model (params X detectors)
1136 UINT4 nscale_flag; //flag to tell likelihood function if psd fitting is in use
1137
1138 REAL8Vector *nscale_prior = NULL; //std. dev. of prior distribution
1139 REAL8Vector *nscale_sigma = NULL; //std. dev. of prior distribution
1140
1141 //assume no noise fitting
1142 nscale_flag=0;
1143
1144 //set Nblock to default unless specified at command line
1145 ppt = LALInferenceGetProcParamVal(commandLine, "--psdNblock");
1146 if(ppt) nscale_block = atoi(ppt->value);
1147 else nscale_block = 8;
1148
1149 //First, figure out sizes of dataset to set up noise blocks
1150 UINT4 nifo; //number of data channels
1151 UINT4 imin; //minimum Fourier bin for integration in IFO
1152 UINT4 imax; //maximum Fourier bin for integration in IFO
1153 UINT4 f_min = 1; //minimum Fourier bin for integration over network
1154 UINT4 f_max = 1; //maximum Fourier bin for integration over network
1155 REAL8 df = 1.0; //frequency resolution
1156
1157 /* Set model sampling rates to be consistent with data */
1158 model->deltaT = state->data->timeData->deltaT;
1159 model->deltaF = state->data->freqData->deltaF;
1160
1161 /* Get number of interferometers */
1162 nifo=0;
1163 dataPtr = state->data;
1164 while (dataPtr != NULL)
1165 {
1166 df = 1.0 / (((double)dataPtr->timeData->data->length) * model->deltaT);
1167 imin = (UINT4)ceil( dataPtr->fLow / df);
1168 imax = (UINT4)floor(dataPtr->fHigh / df);
1169
1170 if(nifo==0)
1171 {
1172 f_min=imin;
1173 f_max=imax;
1174 }
1175 else
1176 {
1177 if(imin<f_min)
1178 {
1179 fprintf(stderr,"Warning: Different IFO's have different minimum frequencies -- bad for noise fitting\n");
1180 f_min=imin;
1181 }
1182 if(imax>f_max)
1183 {
1184 fprintf(stderr,"Warning: Different IFO's have different minimum frequencies -- bad for noise fitting\n");
1185 f_max=imax;
1186 }
1187 }
1188
1189 dataPtr = dataPtr->next;
1190 nifo++;
1191 }
1192 imin = f_min;
1193 imax = f_max;
1194
1195 UINT4 j = 0;
1196
1197 ppt = LALInferenceGetProcParamVal(commandLine, "--psdFit");
1198 if (ppt) {
1199 printf("WARNING: --psdFit has been deprecated in favor of --psd-fit\n");
1200 } else {
1201 ppt = LALInferenceGetProcParamVal(commandLine, "--psd-fit");
1202 }
1203 if(ppt)//MARK: Here is where noise PSD parameters are being added to the model
1204 {
1205
1206 printf("Setting up PSD fitting for %i ifos...\n",nifo);
1207
1208 dataPtr = state->data;
1209
1210 gsl_matrix *bands_min = gsl_matrix_alloc(nifo,nscale_block);
1211 gsl_matrix *bands_max = gsl_matrix_alloc(nifo,nscale_block);
1212
1213 i=0;
1214 while (dataPtr != NULL)
1215 {
1216 printf("ifo=%i %s\n",i,dataPtr->name);fflush(stdout);
1217
1218 nscale_bin = (imax+1-imin)/nscale_block;
1219 nscale_dflog = log( (double)(imax+1)/(double)imin )/(double)nscale_block;
1220
1221 int freq_min, freq_max;
1222
1223 for (j = 0; j < nscale_block; j++)
1224 {
1225
1226 freq_min = (int) exp(log((double)imin ) + nscale_dflog*j);
1227 freq_max = (int) exp(log((double)imin ) + nscale_dflog*(j+1));
1228
1229 gsl_matrix_set(bands_min,i,j,freq_min);
1230 gsl_matrix_set(bands_max,i,j,freq_max);
1231 }
1232
1233
1234 dataPtr = dataPtr->next;
1235 i++;
1236
1237 }
1238
1239 printf("Running PSD fitting with bands (Hz)...\n");
1240 dataPtr = state->data;
1241 i=0;
1242 while (dataPtr != NULL)
1243 {
1244 printf("%s:",dataPtr->name);
1245 for (j = 0; j < nscale_block; j++)
1246 {
1247 printf(" %f-%f ",gsl_matrix_get(bands_min,i,j)*df,gsl_matrix_get(bands_max,i,j)*df);
1248 }
1249 printf("\n");
1250 dataPtr = dataPtr->next;
1251 i++;
1252 }
1253
1254 nscale_bin = (f_max+1-f_min)/nscale_block;
1255 nscale_dflog = log( (double)(f_max+1)/(double)f_min )/(double)nscale_block;
1256
1257 nscale_min = 1.0e-1;
1258 nscale_max = 1.0e+1;
1259 nscale_dim = nscale_block*nifo;
1260 nscale_flag = 1;
1261
1262 // Set noise parameter arrays.
1263 nscale_prior = XLALCreateREAL8Vector(nscale_block);
1264 nscale_sigma = XLALCreateREAL8Vector(nscale_block);
1265 for(i=0; i<nscale_block; i++)
1266 {
1267 nscale_prior->data[i] = 1.0/sqrt( gsl_matrix_get(bands_max,0,i)-gsl_matrix_get(bands_min,0,i) );
1268 nscale_sigma->data[i] = nscale_prior->data[i]/sqrt((double)(nifo*nscale_block));
1269 }
1270
1271 gsl_matrix *nscale = gsl_matrix_alloc(nifo,nscale_block);
1272 gsl_matrix_set_all(nscale, 1.0);
1273
1276
1279
1280 //Set up noise priors
1281 LALInferenceAddVariable(priorArgs, "psddim", &nscale_dim, LALINFERENCE_INT4_t, LALINFERENCE_PARAM_FIXED);
1282 LALInferenceAddMinMaxPrior(priorArgs, "psdscale", &nscale_min, &nscale_max, LALINFERENCE_REAL8_t);
1283 LALInferenceAddMinMaxPrior(priorArgs, "psdrange", &nscale_min, &nscale_max, LALINFERENCE_REAL8_t);
1284 LALInferenceAddVariable(priorArgs, "psdsigma", &nscale_prior, LALINFERENCE_REAL8Vector_t, LALINFERENCE_PARAM_FIXED);
1285
1286 //Store meta data for noise model in proposal
1287 LALInferenceAddVariable(proposalArgs, "psdblock", &nscale_block, LALINFERENCE_INT4_t, LALINFERENCE_PARAM_FIXED);
1288 LALInferenceAddVariable(proposalArgs, "psdbin", &nscale_bin, LALINFERENCE_INT4_t, LALINFERENCE_PARAM_FIXED);
1289 LALInferenceAddVariable(proposalArgs, "psdsigma", &nscale_sigma, LALINFERENCE_REAL8Vector_t, LALINFERENCE_PARAM_FIXED);
1290
1291
1292 }//End of noise model initialization
1293 LALInferenceAddVariable(model->params, "psdScaleFlag", &nscale_flag, LALINFERENCE_UINT4_t, LALINFERENCE_PARAM_FIXED);
1294
1295 UINT4 psdGaussianPrior=1;
1296 ppt = LALInferenceGetProcParamVal(commandLine, "--psdFlatPrior");
1297 if(ppt)psdGaussianPrior=0;
1298 LALInferenceAddVariable(priorArgs, "psdGaussianPrior", &psdGaussianPrior, LALINFERENCE_INT4_t, LALINFERENCE_PARAM_FIXED);
1299
1300 ppt = LALInferenceGetProcParamVal(commandLine, "--glitchFit");
1301 if (ppt)
1302 printf("WARNING: --glitchFit has been deprecated in favor of --glitch-fit\n");
1303 else
1304 ppt = LALInferenceGetProcParamVal(commandLine, "--glitch-fit");
1305 if (ppt)
1307
1308 /* Handle, if present, requests for calibration parameters. */
1310
1311 //Only add waveform parameters to model if needed
1312 if(signal_flag)
1313 {
1314 /* The idea here is the following:
1315 * We call RegisterUniformVariable with startval=0 and meanigful min and max values.
1316 * That function will then take care of setting startval to a random value between min and max, or read a value from command line (with --parname VALUE).
1317 * The user can fix the param to a given value with --fix-parname --parname VALUE
1318 * */
1319 LALInferenceRegisterUniformVariableREAL8(state, model->params, "chirpmass", zero, mcMin, mcMax, LALINFERENCE_PARAM_LINEAR);
1320 /* Check if running with symmetric (eta) or asymmetric (q) mass ratio.*/
1321 ppt=LALInferenceGetProcParamVal(commandLine,"--use-eta");
1322 if(ppt)
1323 LALInferenceRegisterUniformVariableREAL8(state, model->params, "eta", zero, etaMin, etaMax, LALINFERENCE_PARAM_LINEAR);
1324 else
1325 LALInferenceRegisterUniformVariableREAL8(state, model->params, "q", zero, qMin, qMax, LALINFERENCE_PARAM_LINEAR);
1326
1327
1328 if(!LALInferenceGetProcParamVal(commandLine,"--margphi") && !LALInferenceGetProcParamVal(commandLine, "--margtimephi")){
1329 LALInferenceRegisterUniformVariableREAL8(state, model->params, "phase", zero, phiMin, phiMax, LALINFERENCE_PARAM_CIRCULAR);
1330 }
1331
1332 /* Check for distance prior for use if the user samples in logdistance */
1333 if((ppt=LALInferenceGetProcParamVal(commandLine,"--distance-max"))) Dmax=atof(ppt->value);
1334 if((ppt=LALInferenceGetProcParamVal(commandLine,"--distance-min"))) Dmin=atof(ppt->value);
1336 if((ppt=LALInferenceGetProcParamVal(commandLine,"--fix-distance")))
1337 {
1338 Dinitial=atof(ppt->value);
1339 distanceVary = LALINFERENCE_PARAM_FIXED;
1340 }
1341
1342 LALInferenceRegisterUniformVariableREAL8(state, model->params, "logdistance", log(Dinitial), log(Dmin), log(Dmax), distanceVary) ;
1343 if(LALInferenceGetProcParamVal(commandLine,"--margdist")||LALInferenceGetProcParamVal(commandLine,"--margdist-comoving"))
1344 {
1345 /* If using margdist, remove the distance parameters and add the ranges into the model params as a way of passing them in */
1346 REAL8 a = log(Dmin), b=log(Dmax);
1347 LALInferenceAddMinMaxPrior(model->params, "logdistance", &a, &b, LALINFERENCE_REAL8_t);
1348 UINT4 margdist=1;
1349 int cosmology=0;
1351 LALInferenceRemoveVariable(model->params, "logdistance");
1352 if(LALInferenceGetProcParamVal(commandLine,"--margdist-comoving"))
1353 cosmology=1;
1354 LALInferenceAddINT4Variable(model->params,"MARGDIST_COSMOLOGY",cosmology, LALINFERENCE_PARAM_FIXED);
1355 }
1356
1357 LALInferenceRegisterUniformVariableREAL8(state, model->params, "polarisation", zero, psiMin, psiMax, LALINFERENCE_PARAM_LINEAR);
1358 LALInferenceRegisterUniformVariableREAL8(state, model->params, "costheta_jn", zero, costhetaJNmin, costhetaJNmax,LALINFERENCE_PARAM_LINEAR);
1359
1360 /* Option to use the detector-aligned frame */
1361 if(!LALInferenceGetProcParamVal(commandLine,"--no-detector-frame") && nifo >1)
1362 {
1363 printf("Using detector-based sky frame\n");
1364 LALInferenceRegisterUniformVariableREAL8(state,model->params,"t0",timeParam,timeMin,timeMax,LALINFERENCE_PARAM_LINEAR);
1367 /* add the time parameter then remove it so that the prior is set up properly */
1368 LALInferenceRegisterUniformVariableREAL8(state, model->params, "time", timeParam, timeMin, timeMax,LALINFERENCE_PARAM_LINEAR);
1369 LALInferenceRemoveVariable(model->params,"time");
1370 INT4 one=1;
1372 }
1373 else
1374 {
1375 LALInferenceRegisterUniformVariableREAL8(state, model->params, "rightascension", zero, raMin, raMax,LALINFERENCE_PARAM_CIRCULAR);
1376 LALInferenceRegisterUniformVariableREAL8(state, model->params, "declination", zero, decMin, decMax, LALINFERENCE_PARAM_LINEAR);
1377 LALInferenceRegisterUniformVariableREAL8(state, model->params, "time", timeParam, timeMin, timeMax,LALINFERENCE_PARAM_LINEAR);
1378 }
1379
1380 /* If we are marginalising over the time, remove that variable from the model (having set the prior above) */
1381 /* Also set the prior in model->params, since Likelihood can't access the state! (ugly hack) */
1382 if(LALInferenceGetProcParamVal(commandLine,"--margtime") || LALInferenceGetProcParamVal(commandLine, "--margtimephi")){
1384 LALInferenceAddVariable(model->params,"time_min",p->value,p->type,p->vary);
1385 p=LALInferenceGetItem(state->priorArgs,"time_max");
1386 LALInferenceAddVariable(model->params,"time_max",p->value,p->type,p->vary);
1387 if (LALInferenceCheckVariable(model->params,"time")) LALInferenceRemoveVariable(model->params,"time");
1389 if (LALInferenceGetProcParamVal(commandLine, "--margtimephi")) {
1390 UINT4 margphi = 1;
1392 }
1393 }
1394
1395 /* If requested by the user populate the testing GR or PPE model parameters */
1396 if (LALInferenceGetProcParamVal(commandLine,"--grtest-parameters") || LALInferenceGetProcParamVal(commandLine,"--ppe-parameters") || LALInferenceGetProcParamVal(commandLine,"--generic-fd-correction") || LALInferenceGetProcParamVal(commandLine,"--qnmtest-parameters"))
1397 {
1398 LALInferenceInitNonGRParams(state, model);
1399 }
1400 if (LALInferenceGetProcParamVal(commandLine,"--grtest-parameters"))
1401 {
1402 ppt=LALInferenceGetProcParamVal(commandLine,"--grtest-parameters");
1403 if ((checkParamInList(ppt->value,"log10lambda_eff")) || (checkParamInList(ppt->value,"lambda_eff")) ){
1405 {
1406 XLALPrintWarning("LIV parameters not compatible with approximant %s. Can be used only with IMRPhenomPv2, IMRPhenomD, SEOBNRv4_ROM, IMRPhenomPv2_NRTidalv2, IMRPhenomPv3HM, IMRPhenomHM, and IMRPhenomPv2_NRTidal.\n",XLALSimInspiralGetStringFromApproximant(approx));
1407 }
1408 }
1409 }
1410 /* PPE parameters */
1411
1412 ppt=LALInferenceGetProcParamVal(commandLine, "--TaylorF2ppE");
1413 if(approx==TaylorF2 && ppt){
1414
1415 LALInferenceRegisterUniformVariableREAL8(state, model->params, "ppealpha",zero, -1000.0 , 1000.0 , LALINFERENCE_PARAM_LINEAR);
1416 LALInferenceRegisterUniformVariableREAL8(state, model->params, "ppebeta", zero, -1000.0 , 1000.0 , LALINFERENCE_PARAM_LINEAR);
1417 LALInferenceRegisterUniformVariableREAL8(state, model->params, "ppeuppera", zero, -3.0, 3.0 , LALINFERENCE_PARAM_LINEAR);
1418 LALInferenceRegisterUniformVariableREAL8(state, model->params, "ppeupperb", zero, -3.0, 3.0 , LALINFERENCE_PARAM_LINEAR);
1419 LALInferenceRegisterUniformVariableREAL8(state, model->params, "ppelowera", zero, -3.0, 2.0/3.0 , LALINFERENCE_PARAM_LINEAR);
1420 LALInferenceRegisterUniformVariableREAL8(state, model->params, "ppelowerb", zero, -4.5, 1.0, LALINFERENCE_PARAM_LINEAR);
1421
1422 }
1423
1424 if((!!LALInferenceGetProcParamVal(commandLine,"--tidalT") + !!LALInferenceGetProcParamVal(commandLine,"--tidal")
1425 + !!LALInferenceGetProcParamVal(commandLine,"--4PolyEOS") + !!LALInferenceGetProcParamVal(commandLine,"--4SpectralDecomp")
1426 + !!LALInferenceGetProcParamVal(commandLine,"--eos") + !!LALInferenceGetProcParamVal(commandLine,"--BinaryLove")) > 1 )
1427 {
1428 XLALPrintError("Error: cannot use more than one of --tidalT, --tidal, --4PolyEOS, --4SpectralDecomp, --eos and --BinaryLove.\n");
1430 }
1431
1432 if(LALInferenceGetProcParamVal(commandLine,"--tidalT")){
1433 LALInferenceRegisterUniformVariableREAL8(state, model->params, "lambdaT", zero, lambdaTMin, lambdaTMax, LALINFERENCE_PARAM_LINEAR);
1434 LALInferenceRegisterUniformVariableREAL8(state, model->params, "dLambdaT", zero, dLambdaTMin, dLambdaTMax, LALINFERENCE_PARAM_LINEAR);
1435 // Pull in tidal parameters (lambda1,lambda2)
1436 } else if(LALInferenceGetProcParamVal(commandLine,"--tidal")){
1437 LALInferenceRegisterUniformVariableREAL8(state, model->params, "lambda1", zero, lambda1Min, lambda1Max, LALINFERENCE_PARAM_LINEAR);
1438 LALInferenceRegisterUniformVariableREAL8(state, model->params, "lambda2", zero, lambda2Min, lambda2Max, LALINFERENCE_PARAM_LINEAR);
1439 // Pull in 4-piece polytrope parameters (logp1,gamma1,gamma2,gamma3)
1440 } else if(LALInferenceGetProcParamVal(commandLine,"--4PolyEOS")){
1441 LALInferenceRegisterUniformVariableREAL8(state, model->params, "logp1", zero, logp1Min, logp1Max, LALINFERENCE_PARAM_LINEAR);
1442 LALInferenceRegisterUniformVariableREAL8(state, model->params, "gamma1", zero, gamma1Min, gamma1Max, LALINFERENCE_PARAM_LINEAR);
1443 LALInferenceRegisterUniformVariableREAL8(state, model->params, "gamma2", zero, gamma2Min, gamma2Max, LALINFERENCE_PARAM_LINEAR);
1444 LALInferenceRegisterUniformVariableREAL8(state, model->params, "gamma3", zero, gamma3Min, gamma3Max, LALINFERENCE_PARAM_LINEAR);
1445 // Pull in spectral decomposition parameters (SDgamma0,SDgamma1,SDgamma2,SDgamma3)
1446 } else if(LALInferenceGetProcParamVal(commandLine,"--4SpectralDecomp")){
1447 LALInferenceRegisterUniformVariableREAL8(state, model->params, "SDgamma0", zero, SDgamma0Min, SDgamma0Max, LALINFERENCE_PARAM_LINEAR);
1448 LALInferenceRegisterUniformVariableREAL8(state, model->params, "SDgamma1", zero, SDgamma1Min, SDgamma1Max, LALINFERENCE_PARAM_LINEAR);
1449 LALInferenceRegisterUniformVariableREAL8(state, model->params, "SDgamma2", zero, SDgamma2Min, SDgamma2Max, LALINFERENCE_PARAM_LINEAR);
1450 LALInferenceRegisterUniformVariableREAL8(state, model->params, "SDgamma3", zero, SDgamma3Min, SDgamma3Max, LALINFERENCE_PARAM_LINEAR);
1451 } else if((ppt=LALInferenceGetProcParamVal(commandLine,"--eos"))){
1452 LALSimNeutronStarEOS *eos=NULL;
1453 errnum=XLAL_SUCCESS;
1455 if(errnum!=XLAL_SUCCESS)
1456 XLAL_ERROR_NULL(errnum,"%s: %s",__func__,XLALErrorString(errnum));
1457
1458 XLAL_TRY(model->eos_fam = XLALCreateSimNeutronStarFamily(eos),errnum);
1459 if(errnum!=XLAL_SUCCESS)
1460 XLAL_ERROR_NULL(errnum,"%s: %s",__func__,XLALErrorString(errnum));
1461 if(!model->eos_fam) XLAL_ERROR_NULL(XLAL_EINVAL, "Unable to initialise EOS family");
1462
1463 // Pull in symmetric tidal deformability (lambdaS) and the uniform variable used to marginlise over the BinaryLove fit uncertainty
1464 } else if((ppt=LALInferenceGetProcParamVal(commandLine,"--BinaryLove"))){
1465 LALInferenceRegisterUniformVariableREAL8(state, model->params, "lambdaS", zero, lambdaSMin, lambdaSMax, LALINFERENCE_PARAM_LINEAR);
1466 LALInferenceRegisterUniformVariableREAL8(state, model->params, "BLuni", 0.5, 0.0, 1.0, LALINFERENCE_PARAM_LINEAR);
1467 }
1468
1469
1470
1471 if(LALInferenceGetProcParamVal(commandLine,"--dQuadMon12")){
1472 LALInferenceRegisterUniformVariableREAL8(state, model->params, "dQuadMon1", zero, dQuadMonMin, dQuadMonMax, LALINFERENCE_PARAM_LINEAR);
1473 LALInferenceRegisterUniformVariableREAL8(state, model->params, "dQuadMon2", zero, dQuadMonMin, dQuadMonMax, LALINFERENCE_PARAM_LINEAR);
1474 }else if(LALInferenceGetProcParamVal(commandLine,"--dQuadMonSA")){
1475 LALInferenceRegisterUniformVariableREAL8(state, model->params, "dQuadMonS", zero, dQuadMonMin, dQuadMonMax, LALINFERENCE_PARAM_LINEAR);
1476 LALInferenceRegisterUniformVariableREAL8(state, model->params, "dQuadMonA", zero, dQuadMonMin, dQuadMonMax, LALINFERENCE_PARAM_LINEAR);
1477 }
1478
1479 if((!!LALInferenceGetProcParamVal(commandLine,"--dQuadMon12") + !!LALInferenceGetProcParamVal(commandLine,"--dQuadMonSA")) > 1 )
1480 {
1481 XLALPrintError("Error: cannot use more than one of --dQuadMon12 and --dQuadMonSA.\n");
1483 }
1484
1486 ppt=LALInferenceGetProcParamVal(commandLine, "--spinOrder");
1487 if(ppt) {
1488 spinO = atoi(ppt->value);
1489 LALInferenceAddVariable(model->params, "spinO", &spinO,
1491 }
1493 ppt=LALInferenceGetProcParamVal(commandLine, "--tidalOrder");
1494 if(ppt) {
1495 tideO = atoi(ppt->value);
1496 LALInferenceAddVariable(model->params, "tideO", &tideO,
1498 }
1499
1500 /* LALInference uses a proprietary spin parameterization, the conversion from which
1501 * assumes the LALSimulations default frame */
1503
1504 model->LALpars = XLALCreateDict();
1508 if((ppt=LALInferenceGetProcParamVal(commandLine,"--numreldata"))) {
1510 fprintf(stdout,"Template will use %s.\n",ppt->value);
1511 }
1512 if (LALInferenceGetProcParamVal(commandLine, "--liv"))
1514
1515 /* Pass custom mode array list to waveform generator */
1516 if((ppt=LALInferenceGetProcParamVal(commandLine,"--modeList"))) {
1517 char *end_str;
1518 char substring[] = "-";
1519 // strtok_r will modify argument in place, since MCMC calls this again later we need to copy to tmp string to avoid chaing command line
1520 char* tempstr = calloc(strlen(ppt->value)+1, sizeof(char));
1521 strcpy(tempstr, ppt->value);
1522 char *modes = strtok_r(tempstr, ",", &end_str);
1523 int ii=0, jj=0;
1524 // These two will be lists containing integers with the pairs of (l,m) to use
1525 // e.g. modes_l[0]=2 and modes_m[0]=-1 means the (l,m)=(2,-1) will be passed on to LALSim
1526 // Eventually the code below loops over the lenght of these array and pass all modes to LALSim
1527 int *modes_l=NULL;
1528 int *modes_m=NULL;
1529 // Counters used to realloc
1530 int m_size=1;
1531 int l_size=1;
1532 fprintf(stdout, "Template will use a custom mode array.\n");
1533 while (modes != NULL) {
1534 int k = 0;
1535 // reads in modes with negative m's first
1536 if (strstr(modes, substring) != NULL) {
1537 char *end_token;
1538 char *token = strtok_r(modes, "-", &end_token);
1539 while (token != NULL) {
1540 if ( k == 0 ) {
1541 modes_l=realloc(modes_l,sizeof(*modes_l)*l_size);
1542 l_size+=1;
1543 modes_l[ii++]= atoi(token);
1544 } else {
1545 modes_m=realloc(modes_m,sizeof(*modes_m)*m_size);
1546 m_size+=1;
1547 modes_m[jj++]= -1 * atoi(token);
1548 }
1549 k += 1;
1550 token = strtok_r(NULL, "-", &end_token);
1551 }
1552 } else {
1553 // now read modes with positive m. These are read in as integer, then module 10 is used to extract the m and l
1554 // FIXME this will break if l or m ever get >10.
1555 int value = atoi(modes);
1556 for (k=2; k>=0; k--) {
1557 if (k == 2) {
1558 modes_m=realloc(modes_m,sizeof(*modes_m)*m_size);
1559 m_size+=1;
1560 modes_m[jj++] = value % 10;
1561 } else if (k == 1) {
1562 modes_l=realloc(modes_l,sizeof(*modes_l)*l_size);
1563 l_size+=1;
1564 modes_l[ii++]= value % 10;
1565 }
1566 value /= 10;
1567 }
1568 }
1569 modes = strtok_r(NULL, ",", &end_str);
1570 }
1571
1572 // Create empty modearray and fills it with the modes
1573 LALValue *ModeArray = XLALSimInspiralCreateModeArray();
1574 for (int idx_i=0; idx_i<ii; idx_i+=1){
1575 fprintf(stdout, "Template will use the l=%d m=%d mode \n", modes_l[idx_i], modes_m[idx_i]);
1576 XLALSimInspiralModeArrayActivateMode(ModeArray, modes_l[idx_i], modes_m[idx_i]);
1577 }
1579 XLALDestroyValue(ModeArray);
1580 }
1581
1582 /* Pass threshold for PhenomXHM Multibanding */
1583 if((ppt=LALInferenceGetProcParamVal(commandLine,"--phenomXHMMband"))) {
1584 REAL8 threshold = atof(ppt->value);
1586 fprintf(stdout,"Template will use phenomXHMMband %s.\n",ppt->value);
1587 }
1588
1589 /* Pass threshold for PhenomXPHM Multibanding of the Euler angles. */
1590 if((ppt=LALInferenceGetProcParamVal(commandLine,"--phenomXPHMMband"))) {
1591 REAL8 threshold = atof(ppt->value);
1593 fprintf(stdout,"Template will use phenomXPHMMband %s.\n",ppt->value);
1594 }
1595
1596 /* Version for the final spin model to use in IMRPhenomXP/IMRPhenomXPHM. */
1597 if((ppt=LALInferenceGetProcParamVal(commandLine,"--phenomXPFinalSpinMod"))) {
1598 REAL8 afversion = atoi(ppt->value);
1600 fprintf(stdout,"Template will use PhenomXPFinalSpinMod %s.\n",ppt->value);
1601 }
1602
1603 /* Version of the Euler angles in the twisting-up of IMRPhenomXP/IMRPhenomXPHM. */
1604 if((ppt=LALInferenceGetProcParamVal(commandLine,"--phenomXPrecVersion"))) {
1605 REAL8 eulerangleversion = atoi(ppt->value);
1607 fprintf(stdout,"Template will use PhenomXPrecVersion %s.\n",ppt->value);
1608 }
1609
1610
1611
1612
1613 fprintf(stdout,"\n\n---\t\t ---\n");
1614 LALInferenceInitSpinVariables(state, model);
1616
1617 if (injTable)
1618 print_flags_orders_warning(injTable,commandLine);
1619
1620 /* Print info about orders and waveflags used for templates */
1621
1622 fprintf(stdout,"Templates will run using Approximant %i (%s), phase order %i, amp order %i, spin order %i tidal order %i in the %s domain.\n",approx,XLALSimInspiralGetStringFromApproximant(approx),PhaseOrder,AmpOrder,(int) spinO, (int) tideO, model->domain==LAL_SIM_DOMAIN_TIME?"time":"frequency");
1623 fprintf(stdout,"---\t\t ---\n\n");
1624 }//end of signal only flag
1625 else
1626 {
1627 /* Print info about orders and waveflags used for templates */
1628 fprintf(stdout,"\n\n------\n");
1629 fprintf(stdout,"Noise only run\n");
1630 fprintf(stdout,"------\n\n");
1631 }
1632
1633 /* Initialize waveform buffers */
1634 model->timehPlus = XLALCreateREAL8TimeSeries("timehPlus",
1635 &(state->data->timeData->epoch),
1636 0.0,
1637 model->deltaT,
1639 state->data->timeData->data->length);
1640 model->timehCross = XLALCreateREAL8TimeSeries("timehCross",
1641 &(state->data->timeData->epoch),
1642 0.0,
1643 model->deltaT,
1645 state->data->timeData->data->length);
1646 model->freqhPlus = XLALCreateCOMPLEX16FrequencySeries("freqhPlus",
1647 &(state->data->freqData->epoch),
1648 0.0,
1649 model->deltaF,
1651 state->data->freqData->data->length);
1652 model->freqhCross = XLALCreateCOMPLEX16FrequencySeries("freqhCross",
1653 &(state->data->freqData->epoch),
1654 0.0,
1655 model->deltaF,
1657 state->data->freqData->data->length);
1658
1659 model->freqhs = XLALCalloc(nifo, sizeof(COMPLEX16FrequencySeries *));
1660 for (i=0; i<nifo; i++)
1662 &(state->data->freqData->epoch),
1663 0.0,
1664 model->deltaF,
1666 state->data->freqData->data->length);
1667
1668 /* Create arrays for holding single-IFO likelihoods, etc. */
1669 model->ifo_loglikelihoods = XLALCalloc(nifo, sizeof(REAL8));
1670 model->ifo_SNRs = XLALCalloc(nifo, sizeof(REAL8));
1671
1672 /* Choose proper template */
1673 model->templt = LALInferenceInitCBCTemplate(state);
1674
1675 /* Use same window and FFT plans on model as data */
1676 model->window = state->data->window;
1677 model->timeToFreqFFTPlan = state->data->timeToFreqFFTPlan;
1678 model->freqToTimeFFTPlan = state->data->freqToTimeFFTPlan;
1679
1680 /* Initialize waveform cache */
1682
1683 return(model);
1684}
1685
1686
1687
1688/* Setup the variable for the evidence calculation test for review */
1689/* 5-sigma ranges for analytic likeliood function */
1690/* https://www.lsc-group.phys.uwm.edu/ligovirgo/cbcnote/LALInferenceReviewAnalyticGaussianLikelihood */
1692{
1693 LALInferenceIFOData *dataPtr;
1694 INT4 nifo=0;
1695 ProcessParamsTable *commandLine=state->commandLine;
1696 ProcessParamsTable *ppt=NULL;
1697 char **strings=NULL;
1698 char *pinned_params=NULL;
1699 UINT4 N=0,i;
1700 if((ppt=LALInferenceGetProcParamVal(commandLine,"--pinparams"))){
1701 pinned_params=ppt->value;
1702 LALInferenceVariables tempParams;
1703 memset(&tempParams,0,sizeof(tempParams));
1704 LALInferenceParseCharacterOptionString(pinned_params,&strings,&N);
1705 }
1706
1707 LALInferenceModel *model = XLALCalloc(1, sizeof(LALInferenceModel));
1708 model->params = XLALCalloc(1, sizeof(LALInferenceVariables));
1709
1710 dataPtr = state->data;
1711 while (dataPtr != NULL) {
1712 nifo++;
1713 dataPtr = dataPtr->next;
1714 }
1715
1716 /* Create arrays for holding single-IFO likelihoods, etc. */
1717 model->ifo_loglikelihoods = XLALCalloc(nifo, sizeof(REAL8));
1718 model->ifo_SNRs = XLALCalloc(nifo, sizeof(REAL8));
1719
1720 i=0;
1721
1722 /* Parameter bounds at ±5 sigma */
1723 fprintf(stdout,"Setting up priors\n");
1725 for(i=0;i<15;i++)
1726 {
1727 REAL8 min = LALInferenceAnalyticMeansCBC[i] - 5.0/scaling[i]*sqrt(CM[i][i]);
1728 REAL8 max = LALInferenceAnalyticMeansCBC[i] + 5.0/scaling[i]*sqrt(CM[i][i]);
1730 fprintf(stdout,"%s: %e - %e\n",LALInferenceAnalyticNamesCBC[i],min,max);
1731 }
1732
1733 return(model);
1734}
1735
1736
1738{
1739 LALInferenceIFOData *dataPtr;
1740 INT4 nifo=0;
1741 ProcessParamsTable *commandLine=state->commandLine;
1742 ProcessParamsTable *ppt=NULL;
1743 char **strings=NULL;
1744 char *pinned_params=NULL;
1745 UINT4 N=0,i;
1746 if((ppt=LALInferenceGetProcParamVal(commandLine,"--pinparams"))){
1747 pinned_params=ppt->value;
1748 LALInferenceVariables tempParams;
1749 memset(&tempParams,0,sizeof(tempParams));
1750 LALInferenceParseCharacterOptionString(pinned_params,&strings,&N);
1751 }
1752
1753 LALInferenceModel *model = XLALCalloc(1, sizeof(LALInferenceModel));
1754 model->params = XLALCalloc(1, sizeof(LALInferenceVariables));
1755
1756 dataPtr = state->data;
1757 while (dataPtr != NULL) {
1758 nifo++;
1759 dataPtr = dataPtr->next;
1760 }
1761
1762 /* Create arrays for holding single-IFO likelihoods, etc. */
1763 model->ifo_loglikelihoods = XLALCalloc(nifo, sizeof(REAL8));
1764 model->ifo_SNRs = XLALCalloc(nifo, sizeof(REAL8));
1765
1766 i=0;
1767
1768 /* Parameter bounds ± 5 sigma from 2 modes separated by 8 sigma */
1770 fprintf(stdout,"Setting up priors\n");
1771 for(i=0;i<15;i++)
1772 {
1773 REAL8 min = LALInferenceAnalyticMeansCBC[i] - (4.0+5.0)/scaling[i]*sqrt(CM[i][i]);
1774 REAL8 max = LALInferenceAnalyticMeansCBC[i] + (4.0+5.0)/scaling[i]*sqrt(CM[i][i]);
1776 fprintf(stdout,"%s: %e - %e\n",LALInferenceAnalyticNamesCBC[i],min,max);
1777 }
1778
1779 return(model);
1780}
1781
1783{
1784 LALInferenceIFOData *dataPtr;
1785 INT4 nifo = 0;
1786 ProcessParamsTable *commandLine=state->commandLine;
1787 ProcessParamsTable *ppt=NULL;
1788 char **strings=NULL;
1789 char *pinned_params=NULL;
1790 UINT4 N=0,i,j;
1791 if((ppt=LALInferenceGetProcParamVal(commandLine,"--pinparams"))){
1792 pinned_params=ppt->value;
1793 LALInferenceVariables tempParams;
1794 memset(&tempParams,0,sizeof(tempParams));
1795 LALInferenceParseCharacterOptionString(pinned_params,&strings,&N);
1796 }
1797
1798 LALInferenceModel *model = XLALCalloc(1, sizeof(LALInferenceModel));
1799 model->params = XLALCalloc(1, sizeof(LALInferenceVariables));
1800
1801 dataPtr = state->data;
1802 while (dataPtr != NULL) {
1803 nifo++;
1804 dataPtr = dataPtr->next;
1805 }
1806
1807 /* Create arrays for holding single-IFO likelihoods, etc. */
1808 model->ifo_loglikelihoods = XLALCalloc(nifo, sizeof(REAL8));
1809 model->ifo_SNRs = XLALCalloc(nifo, sizeof(REAL8));
1810
1811 i=0;
1812
1813 struct varSettings {const char *name; REAL8 val, min, max;};
1814
1815 struct varSettings setup[]=
1816 {
1817 {.name="time", .val=0.0, .min=-2., .max=2.},
1818 {.name="mass1", .val=16., .min=14., .max=18.},
1819 {.name="mass2", .val=7., .min=5., .max=9.},
1820 {.name="logdistance", .val=log(50.), .min=log(45.), .max=log(55.)},
1821 {.name="costheta_jn", .val=cos(LAL_PI/2.), .min=cos(3.570796327), .max=cos(-0.429203673)},
1822 {.name="phase", .val=LAL_PI, .min=1.141592654, .max=5.141592654},
1823 {.name="polarisation", .val=LAL_PI/2., .min=-0.429203673, .max=3.570796327},
1824 {.name="rightascension", .val=LAL_PI, .min=1.141592654, .max=5.141592654},
1825 {.name="declination", .val=0., .min=-2., .max=2.},
1826 {.name="a_spin1", .val=0.5, .min=-1.5, .max=2.5},
1827 {.name="a_spin2", .val=0.5, .min=-1.5, .max=2.5},
1828 {.name="tilt_spin1", .val=LAL_PI/2., .min=-0.429203673, .max=3.570796327},
1829 {.name="tilt_spin2", .val=LAL_PI/2., .min=-0.429203673, .max=3.570796327},
1830 {.name="phi12", .val=LAL_PI, .min=1.141592654, .max=5.141592654},
1831 {.name="phi_jl", .val=LAL_PI, .min=1.141592654, .max=5.141592654},
1832 {.name="END", .val=0., .min=0., .max=0.}
1833 };
1834
1835 while(strcmp("END",setup[i].name))
1836 {
1838 /* Check if it is to be fixed */
1839 for(j=0;j<N;j++) if(!strcmp(setup[i].name,strings[j])) {type=LALINFERENCE_PARAM_FIXED; printf("Fixing parameter %s\n",setup[i].name); break;}
1840 LALInferenceRegisterUniformVariableREAL8(state, model->params, setup[i].name, setup[i].val, setup[i].min, setup[i].max, type);
1841 i++;
1842 }
1843 return(model);
1844}
1845
1847
1848 /* If lalDebugLevel > 0, print information about:
1849 *
1850 * - Eventual injection/template mismatch on phase and amplitude orders, as well as on waveFlags
1851 * - Those fiels being set only for injection or template
1852 *
1853 **/
1854 XLALPrintWarning("\n");
1855 LALPNOrder PhaseOrder=-1;
1856 LALPNOrder AmpOrder=-1;
1860 ProcessParamsTable *ppt=NULL;
1861 ProcessParamsTable *ppt_order=NULL;
1862 int errnum;
1863 ppt=LALInferenceGetProcParamVal(commline,"--approximant");
1864 if(ppt){
1866 ppt=LALInferenceGetProcParamVal(commline,"--order");
1867 if(ppt) PhaseOrder = XLALGetOrderFromString(ppt->value);
1868 }
1869 ppt=LALInferenceGetProcParamVal(commline,"--approx");
1870 if(ppt){
1872 XLAL_TRY(PhaseOrder = XLALGetOrderFromString(ppt->value),errnum);
1873 if( (int) PhaseOrder == XLAL_FAILURE || errnum) {
1874 XLALPrintWarning("WARNING: No phase order given. Using maximum available order for the template.\n");
1875 PhaseOrder=-1;
1876 }
1877 }
1878 /* check approximant is given */
1879 if (approx==NumApproximants){
1881 XLALPrintWarning("WARNING: You did not provide an approximant for the templates. Using value in injtable (%s), which might not what you want!\n",XLALSimInspiralGetStringFromApproximant(approx));
1882 }
1883
1884 /* check inj/rec amporder */
1885 ppt=LALInferenceGetProcParamVal(commline,"--amporder");
1886 if(ppt) AmpOrder=atoi(ppt->value);
1887 ppt=LALInferenceGetProcParamVal(commline,"--ampOrder");
1888 if(ppt) AmpOrder = XLALGetOrderFromString(ppt->value);
1889 if(AmpOrder!=(LALPNOrder)injt->amp_order)
1890 XLALPrintWarning("WARNING: Injection specified amplitude order %i. Template will use %i\n",
1891 injt->amp_order,AmpOrder);
1892
1893 /* check inj/rec phase order */
1894 if(PhaseOrder!=(LALPNOrder)XLALGetOrderFromString(injt->waveform))
1895 XLALPrintWarning("WARNING: Injection specified phase order %i. Template will use %i\n",\
1896 XLALGetOrderFromString(injt->waveform),PhaseOrder);
1897
1898 /* check inj/rec spinflag */
1899 ppt=LALInferenceGetProcParamVal(commline, "--spinOrder");
1900 ppt_order=LALInferenceGetProcParamVal(commline, "--inj-spinOrder");
1901 if (ppt && ppt_order){
1902 if (!(atoi(ppt->value)== atoi(ppt_order->value)))
1903 XLALPrintWarning("WARNING: Set different spin orders for injection (%i ) and template (%i) \n",atoi(ppt_order->value),atoi(ppt->value));
1904 }
1905 else if (ppt || ppt_order){
1906 if (ppt)
1907 XLALPrintWarning("WARNING: You set the spin order only for the template (%i). Injection will use default value (%i). You can change that with --inj-spinOrder. \n",atoi(ppt->value),default_spinO);
1908 else
1909 XLALPrintWarning("WARNING: You set the spin order only for the injection (%i). Template will use default value (%i). You can change that with --spinOrder. \n",atoi(ppt_order->value),default_spinO); }
1910 else
1911 XLALPrintWarning("WARNING: You did not set the spin order. Injection and template will use default values (%i). You change that using --inj-spinOrder (set injection value) and --spinOrder (set template value).\n",default_spinO);
1912 /* check inj/rec tidal flag */
1913 ppt=LALInferenceGetProcParamVal(commline, "--tidalOrder");
1914 ppt_order=LALInferenceGetProcParamVal(commline, "--inj-tidalOrder");
1915 if (ppt && ppt_order){
1916 if (!(atoi(ppt->value)==atoi( ppt_order->value)))
1917 XLALPrintWarning("WARNING: Set different tidal orders for injection (%i ) and template (%i) \n",atoi(ppt_order->value),atoi(ppt->value));
1918 }
1919 else if (ppt || ppt_order){
1920 if (ppt)
1921 XLALPrintWarning("WARNING: You set the tidal order only for the template (%d). Injection will use default value (%i). You can change that with --inj-tidalOrder. \n",atoi(ppt->value),default_tideO);
1922 else
1923 XLALPrintWarning("WARNING: You set the tidal order only for the injection (%i). Template will use default value (%i). You can change that with --tidalOrder\n",atoi(ppt_order->value),default_tideO);
1924 }
1925 else
1926 XLALPrintWarning("WARNING: You did not set the tidal order. Injection and template will use default values (%i). You change that using --inj-tidalOrder (set injection value) and --tidalOrder (set template value).\n",default_tideO);
1927 return;
1928}
1929
1931
1932{ /*
1933 Go through options and check for possible errors and inconsistencies (e.g. seglen < 0 )
1934
1935 */
1936
1937 ProcessParamsTable *ppt=NULL,*ppt2=NULL;
1938 REAL8 tmp=0.0;
1939 INT4 itmp=0;
1940
1941 ppt=LALInferenceGetProcParamVal(commandLine,"--help");
1942 if (ppt)
1943 return;
1944
1945 // Check PSDlength > 0 if specified
1946 ppt=LALInferenceGetProcParamVal(commandLine,"--psdlength");
1947 if (ppt) {
1948 tmp=atof(ppt->value);
1949 if (tmp<0.0){
1950 fprintf(stderr,"ERROR: PSD length must be positive. Exiting...\n");
1951 exit(1);
1952 }
1953 }
1954
1955 // Check seglen > 0
1956 REAL8 seglen=0.;
1957 ppt=LALInferenceGetProcParamVal(commandLine,"--seglen");
1958 if (!ppt){
1959 XLALPrintError("Must provide segment length with --seglen. Exiting...");
1960 exit(1);
1961 }
1962 else seglen=atof(ppt->value);
1963
1964 tmp=atof(ppt->value);
1965 if (tmp<0.0){
1966 fprintf(stderr,"ERROR: seglen must be positive. Exiting...\n");
1967 exit(1);
1968 }
1969 REAL8 timeSkipStart=0.;
1970 REAL8 timeSkipEnd=0.;
1971 if((ppt=LALInferenceGetProcParamVal(commandLine,"--time-pad-start")))
1972 timeSkipStart=atof(ppt->value);
1973 if((ppt=LALInferenceGetProcParamVal(commandLine,"--time-pad-end")))
1974 timeSkipEnd=atof(ppt->value);
1975 if(timeSkipStart+timeSkipEnd > seglen)
1976 {
1977 fprintf(stderr,"ERROR: --time-pad-start + --time-pad-end is greater than --seglen!");
1978 exit(1);
1979 }
1980
1981 /* Flags consistency */
1982 ppt=LALInferenceGetProcParamVal(commandLine,"--disable-spin");
1983 ppt2=LALInferenceGetProcParamVal(commandLine,"--noSpin");
1984 if (ppt || ppt2){
1985 ppt2=LALInferenceGetProcParamVal(commandLine,"--spinO");
1986 if (ppt2){
1987 itmp=atoi(ppt2->value);
1988 if (itmp>0 || itmp==-1)
1989 XLALPrintWarning("--spinO > 0 or -1 will be ignored due to --disable-spin. If you want to include spin terms in the template, remove --disable-spin\n");
1990 exit(1);
1991 }
1992 if (!ppt2){
1993 XLALPrintWarning("--spinO defaulted to -1. This will be ignored due to --disable-spin. If you want to include spin terms in the template, remove --disable-spin\n");
1994 }
1995 ppt=LALInferenceGetProcParamVal(commandLine, "--spinAligned");
1996 ppt2=LALInferenceGetProcParamVal(commandLine,"--aligned-spin");
1997 if (ppt|| ppt2){
1998 fprintf(stderr,"--aligned-spin and --disable-spin are incompatible options. Exiting\n");
1999 exit(1);
2000 }
2001 ppt=LALInferenceGetProcParamVal(commandLine,"--singleSpin");
2002 if(ppt){
2003 fprintf(stderr,"--singleSpin and --disable-spin are incompatible options. Exiting\n");
2004 exit(1);
2005 }
2006 }
2007
2008 /* lalinference_nest only checks */
2009 // Check live points
2010 ppt=LALInferenceGetProcParamVal(commandLine,"--nlive");
2011 if (ppt){
2012 itmp=atoi(ppt->value);
2013 if (itmp<0){
2014 fprintf(stderr,"ERROR: nlive must be positive. Exiting...\n");
2015 exit(1);
2016 }
2017 if (itmp<100){
2018 XLALPrintWarning("WARNING: Using %d live points. This is very little and may lead to unreliable results. Consider increasing.\n",itmp);
2019 }
2020 if (itmp>5000){
2021 XLALPrintWarning("WARNING: Using %d live points. This is a very large number and may lead to very long runs. Consider decreasing.\n",itmp);
2022 }
2023 }
2024 // Check nmcmc points
2025 ppt=LALInferenceGetProcParamVal(commandLine,"--nmcmc");
2026 if (ppt){
2027 itmp=atoi(ppt->value);
2028 if (itmp<0){
2029 fprintf(stderr,"ERROR: nmcmc must be positive (or omitted). Exiting...\n");
2030 exit(1);
2031 }
2032 if (itmp<100){
2033 XLALPrintWarning("WARNING: Using %d nmcmc. This is very little and may lead to unreliable results. Consider increasing.\n",itmp);
2034 }
2035 }
2036
2037 /* Ensure that the user is not trying to marginalise the likelihood
2038 in an inconsistent way */
2039 if (LALInferenceGetProcParamVal(commandLine, "--margtime") && LALInferenceGetProcParamVal(commandLine, "--margphi")) {
2040 fprintf(stderr, "ERROR: trying to separately marginalise in time and phase. Use '--margtimephi' instead");
2041 exit(1);
2042 }
2043
2044 if (LALInferenceGetProcParamVal(commandLine, "--margtimephi") && LALInferenceGetProcParamVal(commandLine, "--margtime")) {
2045 fprintf(stderr, "ERROR: cannot marginalise in time and phi and separately time. Pick either '--margtimephi' OR '--margtime'");
2046 exit(1);
2047 }
2048
2049 if (LALInferenceGetProcParamVal(commandLine, "--margtimephi") && LALInferenceGetProcParamVal(commandLine, "--margphi")) {
2050 fprintf(stderr, "ERROR: cannot marginalise in time and phi and separately in phi. Pick either '--margtimephi' OR '--margtime'");
2051 exit(1);
2052 }
2053
2054 /* Check for small sample rates when margtime-ing. */
2055 if (LALInferenceGetProcParamVal(commandLine, "--margtime") || LALInferenceGetProcParamVal(commandLine, "--margtimephi")) {
2056 ppt = LALInferenceGetProcParamVal(commandLine, "--srate");
2057 if (ppt) {
2058 int srate = atoi(ppt->value);
2059
2060 if (srate < 4096) {
2061 XLALPrintWarning("WARNING: you have chosen to marginalise in time with a sample rate of %d, but this typically gives incorrect results for CBCs; use at least 4096 Hz to be safe", srate);
2062 }
2063 }
2064 }
2065
2066 return;
2067}
2068
2070
2071
2073 memset(&status,0,sizeof(status));
2074
2075 ProcessParamsTable *commandLine=state->commandLine;
2076 ProcessParamsTable *ppt=NULL;
2077
2078 Approximant approx= *(Approximant*) LALInferenceGetVariable(model->params, "LAL_APPROXIMANT");
2079
2080 REAL8 a1min=0.0,a1max=1.0;
2081 REAL8 a2min=0.0,a2max=1.0;
2082 REAL8 tilt1min=0.0,tilt1max=LAL_PI;
2083 REAL8 tilt2min=0.0,tilt2max=LAL_PI;
2084 REAL8 phi12min=0.0,phi12max=LAL_TWOPI;
2085 REAL8 phiJLmin=0.0,phiJLmax=LAL_TWOPI;
2086
2087 /* Default to precessing spins */
2088 UINT4 spinAligned=0;
2089 UINT4 singleSpin=0;
2090 UINT4 noSpin=0;
2091
2092 /* Let's first check that the user asked, then we check the approximant can make it happen */
2093 /* Check for spin disabled */
2094 ppt=LALInferenceGetProcParamVal(commandLine, "--noSpin");
2095 if (!ppt) ppt=LALInferenceGetProcParamVal(commandLine,"--disable-spin");
2096 if (ppt) noSpin=1;
2097
2098 /* Check for aligned spin */
2099 ppt=LALInferenceGetProcParamVal(commandLine, "--spinAligned");
2100 if (!ppt) ppt=LALInferenceGetProcParamVal(commandLine,"--aligned-spin");
2101 if(ppt)
2102 spinAligned=1;
2103
2104 /* Check for single spin */
2105 ppt=LALInferenceGetProcParamVal(commandLine,"--singleSpin");
2106 if(ppt){
2107 singleSpin=1;
2108 }
2109
2111
2112 /* Now check what the approx can do and eventually change user's choices to comply.
2113 * Also change the reference frame -- For the moment use default as the corresponding patch to LALSimulation has not been finished yet */
2114 if (spin_support==LAL_SIM_INSPIRAL_SPINLESS)
2115 noSpin=1;
2116 else if (spin_support==LAL_SIM_INSPIRAL_SINGLESPIN)
2117 singleSpin=1;
2118 else if (spin_support==LAL_SIM_INSPIRAL_ALIGNEDSPIN){
2119 spinAligned=1;
2120 }
2121
2122 if (spinAligned){
2123 /* If spin aligned the magnitude is in the range [-1,1] */
2124 a1min=-1.0;
2125 a2min=-1.0;
2126 }
2127
2128 /* IMRPhenomP only supports spins up to 0.9 and q > 1/10. Set prior consequently*/
2129 if (approx==IMRPhenomP && (a1max>0.9 || a2max>0.9)){
2130 a1max=0.9;
2131 a2max=0.9;
2132 if (spinAligned){
2133 a1min=-0.9;
2134 a2min=-0.9;
2135 }
2136 XLALPrintWarning("WARNING: IMRPhenomP only supports spin magnitude up to 0.9. Changing the a1max=a2max=0.9.\n");
2137 }
2138
2139 /* IMRPhenomPv2 preliminary only supports spins up to 0.99 and q > 1/20. Set prior consequently*/
2140 if (approx==IMRPhenomPv2 && (a1max>0.99 || a2max>0.99)){
2141 a1max=0.99;
2142 a2max=0.99;
2143 /* If spin-aligned, IMRPhenomPv2 should reduce to IMRPhenomD with a lower spin magnitude of -1.0*/
2144 if (spinAligned){
2145 a1min=-1.0;
2146 a2min=-1.0;
2147 }
2148 XLALPrintWarning("WARNING: IMRPhenomPv2 preliminary only supports spin magnitude up to 0.99. Changing the a1max=a2max=0.99.\n");
2149 }
2150
2151 /* Start with parameters that are free (or pinned if the user wants so). The if...else below may force some of them to be fixed or ignore some of them, depending on the spin configuration*/
2158
2159 /* Add parameters depending on the values of noSpin, singleSpin and spinAligned
2160 * noSpin -> add nothing
2161 * spinAligned -> add a_spin1 and a_spin2 (if the approximant is spin aligned only use the names spin1,spin1 instead)
2162 * singleSpin -> add a_spin1, tilt_spin1, phi_JL
2163 * singleSpin+spinAligned -> add a_spin1
2164 * otherwise -> add everything */
2165 /* Note: To get spin aligned is sufficient to not add the spin angles because LALInferenceTemplate will default to aligned spin if it doesn't find spin angle params in model->params. */
2166 if (!noSpin){
2167 LALInferenceRegisterUniformVariableREAL8(state, model->params, "a_spin1", 0.0, a1min, a1max,spin1Vary);
2168 if (!singleSpin)
2169 LALInferenceRegisterUniformVariableREAL8(state, model->params, "a_spin2", 0.0, a2min, a2max,spin2Vary);
2170 if (!spinAligned){
2171 LALInferenceRegisterUniformVariableREAL8(state, model->params, "phi_jl", 0.0, phiJLmin, phiJLmax, phiJLVary);
2172 LALInferenceRegisterUniformVariableREAL8(state, model->params, "tilt_spin1", 0.0, tilt1min,tilt1max,tilt1Vary);
2173 if (!singleSpin){
2174 LALInferenceRegisterUniformVariableREAL8(state, model->params, "tilt_spin2", 0.0, tilt2min,tilt2max,tilt2Vary);
2175 LALInferenceRegisterUniformVariableREAL8(state, model->params, "phi12", 0.0, phi12min,phi12max,phi12Vary);
2176 }
2177 }
2178 }
2179
2180 /* Print to stdout what will be used */
2181 if (noSpin)
2182 fprintf(stdout,"Templates will run without spins\n");
2183 else{
2184 if (spinAligned && singleSpin)
2185 fprintf(stdout,"Templates will run with spin 1 aligned to L \n");
2186 if (spinAligned && !singleSpin)
2187 fprintf(stdout,"Templates will run with spins aligned to L \n");
2188 if (!spinAligned && singleSpin)
2189 fprintf(stdout,"Templates will run with precessing spin 1 \n");
2190 if (!spinAligned && !singleSpin)
2191 fprintf(stdout,"Templates will run with precessing spins \n");
2192 }
2193}
2194
2196
2198 memset(&status,0,sizeof(status));
2199
2200 ProcessParamsTable *commandLine=state->commandLine;
2201 ProcessParamsTable *ppt=NULL;
2202 LALInferenceVariables *priorArgs=state->priorArgs;
2203
2204 REAL8 m1_min=1.0,m2_min=1.0;
2205 REAL8 m1_max=100.0,m2_max=100.0;
2206 REAL8 MTotMax=200.0;
2207 REAL8 MTotMin=2.0;
2208
2209 /* Over-ride component masses */
2210 if((ppt=LALInferenceGetProcParamVal(commandLine,"--comp-min")))
2211 {
2212 m1_min=m2_min=atof(ppt->value);
2213 }
2214
2215 if((ppt=LALInferenceGetProcParamVal(commandLine,"--comp-max")))
2216 {
2217 m1_max=m2_max=atof(ppt->value);
2218 }
2219
2220 /* optional limits on individual masses */
2221 if((ppt=LALInferenceGetProcParamVal(commandLine,"--mass1-min")))
2222 {
2223 m1_min=atof(ppt->value);
2224 }
2225 if((ppt=LALInferenceGetProcParamVal(commandLine,"--mass1-max")))
2226 {
2227 m1_max = atof(ppt->value);
2228 }
2229 if((ppt=LALInferenceGetProcParamVal(commandLine,"--mass2-min")))
2230 {
2231 m2_min=atof(ppt->value);
2232 }
2233 if((ppt=LALInferenceGetProcParamVal(commandLine,"--mass2-max")))
2234 {
2235 m2_max=atof(ppt->value);
2236 }
2237
2238 /* Set the total mass bounds based on m1,m2 */
2239 MTotMin=m1_min + m2_min;
2240 MTotMax=m1_max + m2_max;
2241
2242 /* Over-ride Mtotal bounds if requested */
2243 if((ppt=LALInferenceGetProcParamVal(commandLine,"--mtotal-max")))
2244 {
2245 MTotMax=atof(ppt->value);
2246 }
2247 if((ppt=LALInferenceGetProcParamVal(commandLine,"--mtotal-min")))
2248 {
2249 MTotMin=atof(ppt->value);
2250 }
2251
2252 LALInferenceAddREAL8Variable(priorArgs,"mass1_min",m1_min,LALINFERENCE_PARAM_FIXED);
2253 LALInferenceAddREAL8Variable(priorArgs,"mass1_max",m1_max,LALINFERENCE_PARAM_FIXED);
2254 LALInferenceAddREAL8Variable(priorArgs,"mass2_min",m2_min,LALINFERENCE_PARAM_FIXED);
2255 LALInferenceAddREAL8Variable(priorArgs,"mass2_max",m2_max,LALINFERENCE_PARAM_FIXED);
2256
2259
2260 return;
2261
2262}
2263
2265
2266 REAL8 min,max;
2267 REAL8 a1min,a1max,a2min,a2max;
2268 UINT4 q=0;
2269
2270 if (LALInferenceCheckVariable(state->priorArgs,"q_min")){
2271 LALInferenceGetMinMaxPrior(state->priorArgs, "q", &min, &max);
2272 q=1;
2273 }
2274 else if (LALInferenceCheckVariable(state->priorArgs,"eta_min"))
2275 LALInferenceGetMinMaxPrior(state->priorArgs, "eta", &min, &max);
2276
2277 /* IMRPhenomP only supports q > 1/10. Set prior consequently */
2278 if (q==1 && approx==IMRPhenomP && min<1./10.){
2279 min=1.0/10.;
2280 LALInferenceRemoveVariable(state->priorArgs,"q_min");
2282 fprintf(stdout,"WARNING: IMRPhenomP only supports mass ratios up to 10 ( suggested max: 4). Changing the min prior for q to 1/10\n");
2283 }
2284 if (q==0 && approx==IMRPhenomP && min<0.08264462810){
2285 min=0.08264462810; //(that is eta for a 1-10 system)
2286 LALInferenceRemoveVariable(state->priorArgs,"eta_min");
2288 fprintf(stdout,"WARNING: IMRPhenomP only supports mass ratios up to 10 ( suggested max: 4). Changing the min prior for eta to 0.083\n");
2289 }
2290
2291 /* In the IMRPhenomD review a region with possible issues (q < 1/10 for maximal spins) was identified */
2292 /* This is not cause to restrict the waveform to exclude this region, but caution should be exercised */
2293 if (approx==IMRPhenomD){
2294 if (LALInferenceCheckMinMaxPrior(state->priorArgs,"a_spin1") && LALInferenceCheckMinMaxPrior(state->priorArgs,"a_spin2")){
2295 LALInferenceGetMinMaxPrior(state->priorArgs, "a_spin1", &a1min, &a1max);
2296 LALInferenceGetMinMaxPrior(state->priorArgs, "a_spin2", &a2min, &a2max);
2297 if (q==1 && min<1./10 && ((a1max==1.0 || a2max==1.0) || (a1min==-1.0 || a2min==-1.0))){
2298 fprintf(stdout,"WARNING: Based on the allowed prior volume (q < 1/10 for maximal spins), please consult\n");
2299 fprintf(stdout,"IMRPhenomD review wiki for further discussion on reliable parameter spaces\n");
2300 fprintf(stdout,"https://www.lsc-group.phys.uwm.edu/ligovirgo/cbcnote/WaveformsReview/IMRPhenomDCodeReview/PhenD_LargeNegativeSpins\n");
2301 }
2302 if (q==0 && min<0.082644628 && ((a1max==1.0 || a2max==1.0) || (a1min==-1.0 || a2min==-1.0))){
2303 fprintf(stdout,"WARNING: Based on the allowed prior volume (q < 1/10 for maximal spins), please consult\n");
2304 fprintf(stdout,"IMRPhenomD review wiki for further discussion on reliable parameter spaces\n");
2305 fprintf(stdout,"https://www.lsc-group.phys.uwm.edu/ligovirgo/cbcnote/WaveformsReview/IMRPhenomDCodeReview/PhenD_LargeNegativeSpins\n");
2306 }
2307 }
2308 }
2309
2310
2311 /* IMRPhenomPv2 only supports q > 1/20. Set prior consequently */
2312 if (q==1 && approx==IMRPhenomPv2 && min<1./20.){
2313 min=1.0/20.;
2314 LALInferenceRemoveVariable(state->priorArgs,"q_min");
2316 fprintf(stdout,"WARNING: IMRPhenomPv2 preliminary only supports mass ratios up to 20 ( suggested max: 18). Changing the min prior for q to 1/20\n");
2317 }
2318 if (q==0 && approx==IMRPhenomPv2 && min<0.04535147392){
2319 min=0.04535147392; //(that is eta for a 1-20 system)
2320 LALInferenceRemoveVariable(state->priorArgs,"eta_min");
2322 fprintf(stdout,"WARNING: IMRPhenomPv2 preliminary only supports mass ratios up to 20 ( suggested max: 20). Changing the min prior for eta to 0.045\n");
2323 }
2324
2325 (void) max;
2326 return;
2327}
2328
2329/*******************************************************************
2330 * LALInferenceInitNonGRParams(LALInferenceRunState *state, LALInferenceModel *model)
2331 * Function to initialise either the TaylorF2Test of SpinTaylorT4Test waveform models
2332 * or the PPE waveform model
2333 *******************************************************************/
2335{
2336 ProcessParamsTable *commandLine = state->commandLine;
2337 ProcessParamsTable *ppt=NULL;
2338 ProcessParamsTable *ppta=NULL;
2339 ProcessParamsTable *pptb=NULL;
2340
2341 INT4 generic_fd_correction = 0;
2342 INT4 generic_fd_correction_hm = 0;
2343 REAL8 correction_window = 1.0;
2344 REAL8 correction_ncycles_taper = 1.0;
2345
2346 /* check that the user does not request both a TaylorF2Test and a PPE waveform model */
2347 UINT2 check_grtest_params = 0;
2348 UINT2 check_ppe_params = 0;
2349 UINT2 check_qnmtest_params = 0;
2350
2351 if (LALInferenceGetProcParamVal(commandLine, "--grtest-parameters")) {
2352 check_grtest_params = 1;
2353 }
2354
2355 if (LALInferenceGetProcParamVal(commandLine, "--ppe-parameters")) {
2356 check_ppe_params = 1;
2357 }
2358
2359 if (LALInferenceGetProcParamVal(commandLine,"--qnmtest-parameters")) {
2360 check_qnmtest_params = 1;
2361 }
2362
2363 if (check_grtest_params + check_ppe_params + check_qnmtest_params >= 2) {
2364 fprintf(stderr,"--grtest-parameters, --ppe-parameters and --qnmtest-parameters are not simultaneously supported. Please choose one. Aborting\n");
2365 exit(-1);
2366 }
2367
2368
2369 ppt=LALInferenceGetProcParamVal(commandLine,"--grtest-parameters");
2370 if (ppt)
2371 {
2372 REAL8 dchi_max=1.;
2373 REAL8 dchi_min=-1.;
2374 REAL8 dxi_max=1.;
2375 REAL8 dxi_min=-1.;
2376 REAL8 dalpha_max=1.;
2377 REAL8 dalpha_min=-1.;
2378 REAL8 dbeta_max=1.;
2379 REAL8 dbeta_min=-1.;
2380 REAL8 dsigma_max=1.;
2381 REAL8 dsigma_min=-1.;
2382 REAL8 dc_min=-1;
2383 REAL8 dc_max=1;
2384 REAL8 db_min=-1;
2385 REAL8 db_max=1;
2386 REAL8 tmpVal=0.0;
2387 if ((pptb=LALInferenceGetProcParamVal(commandLine,"--LIV_A_sign"))) {
2388 REAL8 LIV_A_sign;
2389 LIV_A_sign = atof(pptb->value);
2390 if ((LIV_A_sign != -1) && (LIV_A_sign != 1)) {
2391 XLALPrintError("LIV_A_sign can only take either +1 or -1.\n");
2393 }
2394 else LALInferenceAddVariable(model->params,"LIV_A_sign", &LIV_A_sign, LALINFERENCE_REAL8_t, LALINFERENCE_PARAM_FIXED);
2395 }
2396 if ((ppta=LALInferenceGetProcParamVal(commandLine,"--nonGR_alpha"))) {
2397 REAL8 nonGR_alpha;
2398 nonGR_alpha = atof(ppta->value);
2399 if (nonGR_alpha==2.0) {
2400 XLALPrintError("nonGR_alpha=2 is degenerate with p^2c^2 term in dispersion relation and cannot be tested. Please choose a different value.\n");
2402 }
2403 else LALInferenceAddVariable(model->params,"nonGR_alpha", &nonGR_alpha, LALINFERENCE_REAL8_t, LALINFERENCE_PARAM_FIXED);
2404 }
2405 /* Relative shifts for inspiral phase PN coefficients (absolute value for dchi1) */
2406 if (checkParamInList(ppt->value,"dchiMinus2")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchiMinus2", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2407 if (checkParamInList(ppt->value,"dchiMinus1")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchiMinus1", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2408 if (checkParamInList(ppt->value,"dchi0")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi0", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2409 if (checkParamInList(ppt->value,"dchi1")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi1", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2410 if (checkParamInList(ppt->value,"dchi2")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi2", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2411 if (checkParamInList(ppt->value,"dchi3")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi3", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2412 if (checkParamInList(ppt->value,"dchi3S")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi3S", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2413 if (checkParamInList(ppt->value,"dchi3NS")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi3NS", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2414 if (checkParamInList(ppt->value,"dchi4")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi4", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2415 if (checkParamInList(ppt->value,"dchi4S")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi4S", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2416 if (checkParamInList(ppt->value,"dchi4NS")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi4NS", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2417 if (checkParamInList(ppt->value,"dchi5")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi5", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2418 if (checkParamInList(ppt->value,"dchi5S")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi5S", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2419 if (checkParamInList(ppt->value,"dchi5NS")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi5NS", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2420 if (checkParamInList(ppt->value,"dchi5l")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi5l", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2421 if (checkParamInList(ppt->value,"dchi5lS")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi5lS", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2422 if (checkParamInList(ppt->value,"dchi5lNS")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi5lNS", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2423 if (checkParamInList(ppt->value,"dchi6")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi6", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2424 if (checkParamInList(ppt->value,"dchi6S")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi6S", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2425 if (checkParamInList(ppt->value,"dchi6NS")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi6NS", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2426 if (checkParamInList(ppt->value,"dchi6l")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi6l", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2427 if (checkParamInList(ppt->value,"dchi7")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi7", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2428 if (checkParamInList(ppt->value,"dchi7S")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi7S", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2429 if (checkParamInList(ppt->value,"dchi7NS")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchi7NS", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2430 if (checkParamInList(ppt->value,"dchikappaS")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchikappaS", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2431 if (checkParamInList(ppt->value,"dchikappaA")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dchikappaA", tmpVal, dchi_min, dchi_max, LALINFERENCE_PARAM_LINEAR);
2432
2433 /* Relative shifts for pre-merger phase coefficients (PhenomC/P) */
2434 if (checkParamInList(ppt->value,"dxi1")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dxi1", tmpVal, dxi_min, dxi_max, LALINFERENCE_PARAM_LINEAR);
2435 if (checkParamInList(ppt->value,"dxi2")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dxi2", tmpVal, dxi_min, dxi_max, LALINFERENCE_PARAM_LINEAR);
2436 if (checkParamInList(ppt->value,"dxi3")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dxi3", tmpVal, dxi_min, dxi_max, LALINFERENCE_PARAM_LINEAR);
2437 if (checkParamInList(ppt->value,"dxi4")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dxi4", tmpVal, dxi_min, dxi_max, LALINFERENCE_PARAM_LINEAR);
2438 if (checkParamInList(ppt->value,"dxi5")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dxi5", tmpVal, dxi_min, dxi_max, LALINFERENCE_PARAM_LINEAR);
2439 if (checkParamInList(ppt->value,"dxi6")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dxi6", tmpVal, dxi_min, dxi_max, LALINFERENCE_PARAM_LINEAR);
2440
2441 /* Relative shifts for merger-ringdown phase coefficients (PhenomD/Pv2) */
2442 if (checkParamInList(ppt->value,"dalpha1")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dalpha1", tmpVal, dalpha_min, dalpha_max, LALINFERENCE_PARAM_LINEAR);
2443 if (checkParamInList(ppt->value,"dalpha2")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dalpha2", tmpVal, dalpha_min, dalpha_max, LALINFERENCE_PARAM_LINEAR);
2444 if (checkParamInList(ppt->value,"dalpha3")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dalpha3", tmpVal, dalpha_min, dalpha_max, LALINFERENCE_PARAM_LINEAR);
2445 if (checkParamInList(ppt->value,"dalpha4")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dalpha4", tmpVal, dalpha_min, dalpha_max, LALINFERENCE_PARAM_LINEAR);
2446 if (checkParamInList(ppt->value,"dalpha5")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dalpha5", tmpVal, dalpha_min, dalpha_max, LALINFERENCE_PARAM_LINEAR);
2447
2448 /* Relative shifts for merger-ringdown phase coefficients (PhenomX) */
2449 if (checkParamInList(ppt->value,"dc1")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dc1", tmpVal, dc_min, dc_max, LALINFERENCE_PARAM_LINEAR);
2450 if (checkParamInList(ppt->value,"dc2")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dc2", tmpVal, dc_min, dc_max, LALINFERENCE_PARAM_LINEAR);
2451 if (checkParamInList(ppt->value,"dc4")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dc4", tmpVal, dc_min, dc_max, LALINFERENCE_PARAM_LINEAR);
2452 if (checkParamInList(ppt->value,"dcl")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dcl", tmpVal, dc_min, dc_max, LALINFERENCE_PARAM_LINEAR);
2453
2454 /* Relative shifts for phenomenological inspiral phase coefficients (PhenomD/Pv2) */
2455 if (checkParamInList(ppt->value,"dsigma1")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dsigma1", tmpVal, dsigma_min, dsigma_max, LALINFERENCE_PARAM_LINEAR);
2456 if (checkParamInList(ppt->value,"dsigma2")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dsigma2", tmpVal, dsigma_min, dsigma_max, LALINFERENCE_PARAM_LINEAR);
2457 if (checkParamInList(ppt->value,"dsigma3")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dsigma3", tmpVal, dsigma_min, dsigma_max, LALINFERENCE_PARAM_LINEAR);
2458 if (checkParamInList(ppt->value,"dsigma4")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dsigma4", tmpVal, dsigma_min, dsigma_max, LALINFERENCE_PARAM_LINEAR);
2459
2460 /* Relative shifts for intermediate phase coefficients (PhenomD/Pv2) */
2461 if (checkParamInList(ppt->value,"dbeta1")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dbeta1", tmpVal, dbeta_min, dbeta_max, LALINFERENCE_PARAM_LINEAR);
2462 if (checkParamInList(ppt->value,"dbeta2")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dbeta2", tmpVal, dbeta_min, dbeta_max, LALINFERENCE_PARAM_LINEAR);
2463 if (checkParamInList(ppt->value,"dbeta3")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dbeta3", tmpVal, dbeta_min, dbeta_max, LALINFERENCE_PARAM_LINEAR);
2464
2465 /* Relative shifts for intermediate phase coefficients (PhenomX) */
2466 if (checkParamInList(ppt->value,"db1")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "db1", tmpVal, db_min, db_max, LALINFERENCE_PARAM_LINEAR);
2467 if (checkParamInList(ppt->value,"db2")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "db2", tmpVal, db_min, db_max, LALINFERENCE_PARAM_LINEAR);
2468 if (checkParamInList(ppt->value,"db3")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "db3", tmpVal, db_min, db_max, LALINFERENCE_PARAM_LINEAR);
2469 if (checkParamInList(ppt->value,"db4")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "db4", tmpVal, db_min, db_max, LALINFERENCE_PARAM_LINEAR);
2470
2471 if (checkParamInList(ppt->value,"lambda_eff")) {
2472 if (ppta==NULL) {
2473 XLALPrintError("A value for nonGR_alpha has to be passed with lambda_eff.\n");
2475 }
2476 else if (pptb==NULL) {
2477 XLALPrintError("A value of +1 or -1 for LIV_A_sign has to be passed with lambda_eff, respectively determing if +A or -A in the MDR is being tested.\n");
2479 }
2480 else {
2481 REAL8 lambda_eff_min = 1E-6;
2482 REAL8 lambda_eff_max = 1E13;
2483 LALInferenceRegisterUniformVariableREAL8(state, model->params, "lambda_eff", 1E11, lambda_eff_min, lambda_eff_max, LALINFERENCE_PARAM_LINEAR);
2484 }
2485 }
2486 if (checkParamInList(ppt->value,"log10lambda_eff")) {
2487 if (ppta==NULL) {
2488 XLALPrintError("A value for nonGR_alpha has to be passed with log10lambda_eff. A value for LIV_A_sign also has to be passed!\n");
2490 }
2491 else if (pptb==NULL) {
2492 XLALPrintError("A value of +1 or -1 for LIV_A_sign has to be passed with log10lambda_eff, respectively determing if +A or -A in the MDR is being tested.\n");
2494 }
2495 else {
2496 REAL8 log10lambda_eff_min = -6.0;
2497 REAL8 log10lambda_eff_max = 13.0;
2498 LALInferenceRegisterUniformVariableREAL8(state, model->params, "log10lambda_eff", 3.0, log10lambda_eff_min, log10lambda_eff_max, LALINFERENCE_PARAM_LINEAR);
2499 }
2500 }
2501 }
2502
2503 ppt=LALInferenceGetProcParamVal(commandLine,"--generic-fd-correction");
2504 if (ppt)
2505 {
2506 generic_fd_correction = 1;
2507 LALInferenceAddVariable(model->params,"generic_fd_correction", &generic_fd_correction, LALINFERENCE_INT4_t, LALINFERENCE_PARAM_FIXED);
2508 ppt=LALInferenceGetProcParamVal(commandLine,"--generic-fd-correction-hm");
2509 if (ppt)
2510 {
2511 generic_fd_correction_hm = 1;
2512 LALInferenceAddVariable(model->params,"generic_fd_correction_hm", &generic_fd_correction_hm, LALINFERENCE_INT4_t, LALINFERENCE_PARAM_FIXED);
2513 }
2514 ppt=LALInferenceGetProcParamVal(commandLine,"--generic-fd-correction-window");
2515 if (ppt) correction_window = atof(ppt->value);
2516 LALInferenceAddVariable(model->params,"correction_window", &correction_window, LALINFERENCE_REAL8_t, LALINFERENCE_PARAM_FIXED);
2517 ppt=LALInferenceGetProcParamVal(commandLine,"--generic-fd-correction-ncyles");
2518 if (ppt) correction_ncycles_taper = atof(ppt->value);
2519 LALInferenceAddVariable(model->params,"correction_ncycles_taper", &correction_ncycles_taper, LALINFERENCE_REAL8_t, LALINFERENCE_PARAM_FIXED);
2520 }
2521
2522 ppt=LALInferenceGetProcParamVal(commandLine,"--ppe-parameters");
2523 if (ppt)
2524 {
2525 /* amplitude parameters */
2526 REAL8 appe_min = -5.0,appe_max=5.0;
2527 REAL8 alphappe_min = -1000.0,alphappe_max=1000.0;
2528 REAL8 bppe_min = -5.0,bppe_max=5.0;
2529 REAL8 betappe_min = -1000.0,betappe_max=1000.0;
2530 char aPPEparam[64]="";
2531 char alphaPPEparam[64]="";
2532 /* phase parameters */
2533 char bPPEparam[64]="";
2534 char betaPPEparam[64]="";
2535 int counters[4]={0};
2536 do
2537 {
2538 sprintf(aPPEparam, "%s%d","aPPE",++counters[0]);
2539 if (checkParamInList(ppt->value,aPPEparam)) LALInferenceRegisterUniformVariableREAL8(state, model->params, aPPEparam, 0.0, appe_min, appe_max, LALINFERENCE_PARAM_LINEAR);
2540 sprintf(alphaPPEparam, "%s%d","alphaPPE",++counters[1]);
2541 if (checkParamInList(ppt->value,alphaPPEparam)) LALInferenceRegisterUniformVariableREAL8(state, model->params, alphaPPEparam, 0.0, alphappe_min, alphappe_max, LALINFERENCE_PARAM_LINEAR);
2542 sprintf(bPPEparam, "%s%d","bPPE",++counters[2]);
2543 if (checkParamInList(ppt->value,bPPEparam)) LALInferenceRegisterUniformVariableREAL8(state, model->params, bPPEparam, 0.0, bppe_min, bppe_max, LALINFERENCE_PARAM_LINEAR);
2544 sprintf(betaPPEparam, "%s%d","betaPPE",++counters[3]);
2545 if (checkParamInList(ppt->value,betaPPEparam)) LALInferenceRegisterUniformVariableREAL8(state, model->params, betaPPEparam, 0.0, betappe_min, betappe_max, LALINFERENCE_PARAM_LINEAR);
2546
2547 } while((checkParamInList(ppt->value,aPPEparam))||(checkParamInList(ppt->value,alphaPPEparam))||(checkParamInList(ppt->value,bPPEparam))||(checkParamInList(ppt->value,betaPPEparam)));
2548 if ((counters[0]!=counters[1])||(counters[2]!=counters[3])) {fprintf(stderr,"Unequal number of PPE parameters detected! Check your command line!\n"); exit(-1);}
2549 }
2550 ppt=LALInferenceGetProcParamVal(commandLine,"--qnmtest-parameters");
2551 if (ppt)
2552 {
2553 REAL8 domega_max=1.;
2554 REAL8 domega_min=-1.;
2555 REAL8 dtau_max=1.;
2556 REAL8 dtau_min=-1.;
2557 REAL8 tmpVal=0.0;
2558 /* Relative shifts for ringdown frequencies and inverse damping times (SEOBNRv4HM) */
2559 if (checkParamInList(ppt->value,"domega220")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "domega220", tmpVal, domega_min, domega_max, LALINFERENCE_PARAM_LINEAR);
2560 if (checkParamInList(ppt->value,"dtau220")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dtau220", tmpVal, dtau_min, dtau_max, LALINFERENCE_PARAM_LINEAR);
2561 if (checkParamInList(ppt->value,"domega210")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "domega210", tmpVal, domega_min, domega_max, LALINFERENCE_PARAM_LINEAR);
2562 if (checkParamInList(ppt->value,"dtau210")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dtau210", tmpVal, dtau_min, dtau_max, LALINFERENCE_PARAM_LINEAR);
2563 if (checkParamInList(ppt->value,"domega330")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "domega330", tmpVal, domega_min, domega_max, LALINFERENCE_PARAM_LINEAR);
2564 if (checkParamInList(ppt->value,"dtau330")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dtau330", tmpVal, dtau_min, dtau_max, LALINFERENCE_PARAM_LINEAR);
2565 if (checkParamInList(ppt->value,"domega440")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "domega440", tmpVal, domega_min, domega_max, LALINFERENCE_PARAM_LINEAR);
2566 if (checkParamInList(ppt->value,"dtau440")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dtau440", tmpVal, dtau_min, dtau_max, LALINFERENCE_PARAM_LINEAR);
2567 if (checkParamInList(ppt->value,"domega550")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "domega550", tmpVal, domega_min, domega_max, LALINFERENCE_PARAM_LINEAR);
2568 if (checkParamInList(ppt->value,"dtau550")) LALInferenceRegisterUniformVariableREAL8(state, model->params, "dtau550", tmpVal, dtau_min, dtau_max, LALINFERENCE_PARAM_LINEAR);
2569 }
2570
2571}
LALDict * XLALCreateDict(void)
const REAL8 CM[15][15]
const REAL8 scaling[15]
const char * LALInferenceAnalyticNamesCBC[]
const REAL8 LALInferenceAnalyticMeansCBC[]
LALInferenceModel * LALInferenceInitCBCModel(LALInferenceRunState *state)
Initialise state variables needed for LALInferenceNest or LALInferenceMCMC to run on a CBC signal.
void LALInferenceCheckOptionsConsistency(ProcessParamsTable *commandLine)
Check options consistency.
void LALInferenceRegisterUniformVariableREAL8(LALInferenceRunState *state, LALInferenceVariables *var, const char *name, REAL8 startval, REAL8 min, REAL8 max, LALInferenceParamVaryType varytype)
Register a variable in vars for the model with given name, and a uniform prior.
LALInferenceTemplateFunction LALInferenceInitCBCTemplate(LALInferenceRunState *runState)
Initialise the template for a standard CBC signal.
static void LALInferenceInitSpinVariables(LALInferenceRunState *state, LALInferenceModel *model)
LALInferenceModel * LALInferenceInitModelReviewEvidence_banana(LALInferenceRunState *state)
static int checkParamInList(const char *list, const char *param)
LALInferenceRunState * LALInferenceInitRunState(ProcessParamsTable *command_line)
static void print_flags_orders_warning(SimInspiralTable *injt, ProcessParamsTable *commline)
static void LALInferenceInitMassVariables(LALInferenceRunState *state)
void LALInferenceInitCBCThreads(LALInferenceRunState *run_state, INT4 nthreads)
static void LALInferenceCheckApproximantNeeds(LALInferenceRunState *state, Approximant approx)
void LALInferenceDrawThreads(LALInferenceRunState *run_state)
LALInferenceModel * LALInferenceInitModelReviewEvidence(LALInferenceRunState *state)
Review functions.
#define CAL_ENV_FORMAT
void LALInferenceInitGlitchVariables(LALInferenceRunState *runState, LALInferenceVariables *currentParams)
Initialise the glitch fitting parameters.
void LALInferenceRegisterGaussianVariableREAL8(LALInferenceRunState *state, LALInferenceVariables *var, const char *name, REAL8 startval, REAL8 mean, REAL8 stdev, LALInferenceParamVaryType varytype)
void LALInferenceInitCalibrationVariables(LALInferenceRunState *runState, LALInferenceVariables *currentParams)
static int destroyCalibrationEnvelope(struct spcal_envelope *env)
static void LALInferenceInitNonGRParams(LALInferenceRunState *state, LALInferenceModel *model)
static struct spcal_envelope * initCalibrationEnvelope(char *filename)
LALInferenceModel * LALInferenceInitModelReviewEvidence_bimod(LALInferenceRunState *state)
static REAL8 mean(REAL8 *array, int N)
#define max(a, b)
LALInferenceVariables currentParams
ProcessParamsTable * ppt
int j
int k
int XLALGetOrderFromString(const char *waveform)
int XLALGetApproximantFromString(const char *waveform)
int XLALSimInspiralImplementedFDApproximants(Approximant approximant)
const char * XLALSimInspiralGetStringFromApproximant(Approximant approximant)
int XLALSimInspiralImplementedTDApproximants(Approximant approximant)
int XLALSimInspiralGetSpinSupportFromApproximant(Approximant approx)
int XLALSimInspiralWaveformParamsInsertModeArray(LALDict *params, LALValue *value)
int XLALSimInspiralWaveformParamsInsertNumRelData(LALDict *params, const char *value)
int XLALSimInspiralWaveformParamsInsertPhenomXPHMThresholdMband(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertPhenomXHMThresholdMband(LALDict *params, REAL8 value)
int XLALSimInspiralWaveformParamsInsertFrameAxis(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertPhenomXPFinalSpinMod(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertPNSpinOrder(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertPNTidalOrder(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertPhenomXPrecVersion(LALDict *params, INT4 value)
int XLALSimInspiralWaveformParamsInsertEnableLIV(LALDict *params, INT4 value)
struct tagLALSimNeutronStarEOS LALSimNeutronStarEOS
void XLALDestroyValue(LALValue *value)
SimInspiralTable * XLALSimInspiralTableFromLIGOLw(const char *fileName)
#define fprintf
const char *const name
sigmaKerr data[0]
COMPLEX16FrequencySeries * XLALCreateCOMPLEX16FrequencySeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaF, const LALUnit *sampleUnits, size_t length)
#define LAL_PI
#define LAL_TWOPI
double REAL8
uint16_t UINT2
uint32_t UINT4
int32_t INT4
#define VARNAME_MAX
Definition: LALInference.h:50
void LALInferenceAddVariable(LALInferenceVariables *vars, const char *name, const void *value, LALInferenceVariableType type, LALInferenceParamVaryType vary)
Add a variable named name to vars with initial value referenced by value.
Definition: LALInference.c:395
LALInferenceThreadState * LALInferenceInitThreads(INT4 nthreads)
Definition: LALInference.c:138
REAL8 LALInferenceGetREAL8Variable(LALInferenceVariables *vars, const char *name)
void LALInferenceRemoveVariable(LALInferenceVariables *vars, const char *name)
Remove name from vars Frees the memory for the name structure and its contents.
Definition: LALInference.c:450
LALInferenceParamVaryType
An enumerated type for denoting the topology of a parameter.
Definition: LALInference.h:127
void LALInferenceCopyVariables(LALInferenceVariables *origin, LALInferenceVariables *target)
Deep copy the variables from one to another LALInferenceVariables structure.
Definition: LALInference.c:558
void * LALInferenceGetVariable(const LALInferenceVariables *vars, const char *name)
Return a pointer to the memory the variable vars is stored in specified by name User must cast this p...
Definition: LALInference.c:238
void LALInferenceAddREAL8Variable(LALInferenceVariables *vars, const char *name, REAL8 value, LALInferenceParamVaryType vary)
ProcessParamsTable * LALInferenceGetProcParamVal(ProcessParamsTable *procparams, const char *name)
Returns the element of the process params table with "name".
void LALInferenceAddINT4Variable(LALInferenceVariables *vars, const char *name, INT4 value, LALInferenceParamVaryType vary)
LALInferenceVariableItem * LALInferenceGetItem(const LALInferenceVariables *vars, const char *name)
Return the list node for "name" - do not rely on this.
Definition: LALInference.c:175
void(* LALInferenceTemplateFunction)(struct tagLALInferenceModel *model)
Type declaration for template function, which operates on a LALInferenceIFOData structure *data.
Definition: LALInference.h:377
void LALInferenceParseCharacterOptionString(char *input, char **strings[], UINT4 *n)
parses a character string (passed as one of the options) and decomposes it into individual parameter ...
void LALInferenceClearVariables(LALInferenceVariables *vars)
Delete the variables in this structure.
Definition: LALInference.c:532
int LALInferenceCheckVariable(LALInferenceVariables *vars, const char *name)
Checks for name being present in vars returns 1(==true) or 0.
Definition: LALInference.c:525
void LALInferenceCopyUnsetREAL8Variables(LALInferenceVariables *origin, LALInferenceVariables *target, ProcessParamsTable *commandLine)
Definition: LALInference.c:659
int LALInferenceCheckVariableNonFixed(LALInferenceVariables *vars, const char *name)
Checks for name being present in vars and having type LINEAR or CIRCULAR.
Definition: LALInference.c:503
@ LALINFERENCE_PARAM_OUTPUT
A parameter that never changes, functions should respect this.
Definition: LALInference.h:131
@ LALINFERENCE_PARAM_FIXED
A parameter that is cyclic, such as an angle between 0 and 2pi.
Definition: LALInference.h:130
@ LALINFERENCE_PARAM_CIRCULAR
A parameter that simply has a maximum and a minimum.
Definition: LALInference.h:129
@ LALINFERENCE_PARAM_LINEAR
Definition: LALInference.h:128
@ LALINFERENCE_REAL8_t
Definition: LALInference.h:109
@ LALINFERENCE_INT4_t
Definition: LALInference.h:105
@ LALINFERENCE_REAL8Vector_t
Definition: LALInference.h:113
@ LALINFERENCE_UINT4_t
Definition: LALInference.h:107
@ LALINFERENCE_UINT4Vector_t
Definition: LALInference.h:115
@ LALINFERENCE_gslMatrix_t
Definition: LALInference.h:112
void LALInferenceAddGaussianPrior(LALInferenceVariables *priorArgs, const char *name, REAL8 *mu, REAL8 *sigma, LALInferenceVariableType type)
Function to add the mu and sigma values for the Gaussian prior onto the priorArgs.
int LALInferenceCheckMinMaxPrior(LALInferenceVariables *priorArgs, const char *name)
Check for types of standard prior.
void LALInferenceAddMinMaxPrior(LALInferenceVariables *priorArgs, const char *name, REAL8 *min, REAL8 *max, LALInferenceVariableType type)
Function to add the minimum and maximum values for the uniform prior onto the priorArgs.
void LALInferenceRemoveMinMaxPrior(LALInferenceVariables *priorArgs, const char *name)
Function to remove the minimum and maximum values for the uniform prior onto the priorArgs.
void LALInferenceCyclicReflectiveBound(LALInferenceVariables *parameter, LALInferenceVariables *priorArgs)
Apply cyclic and reflective boundaries to parameter to bring it back within the allowed prior ranges ...
void LALInferenceGetMinMaxPrior(LALInferenceVariables *priorArgs, const char *name, REAL8 *min, REAL8 *max)
Get the minimum and maximum values of the uniform prior from the priorArgs list, given a name.
REAL8 LALInferenceDrawApproxPrior(LALInferenceThreadState *thread, LALInferenceVariables *currentParams, LALInferenceVariables *proposedParams)
Draws from an approximation to the true prior.
void LALInferenceInjectionToVariables(SimInspiralTable *theEventTable, LALInferenceVariables *vars)
Fill the variables passed in vars with the parameters of the injection passed in event will over-writ...
void LALInferenceSetupROQmodel(LALInferenceModel *model, ProcessParamsTable *commandLine)
LALInferenceIFOData * LALInferenceReadData(ProcessParamsTable *commandLine)
Read IFO data according to command line arguments.
void LALInferenceROQWrapperForXLALSimInspiralChooseFDWaveformSequence(LALInferenceModel *model)
void LALInferenceTemplateNullFreqdomain(LALInferenceModel *model)
Returns a frequency-domain 'null' template (all zeroes, implying no signal present).
void LALInferenceTemplateXLALSimInspiralChooseWaveformPhaseInterpolated(LALInferenceModel *model)
void LALInferenceTemplateXLALSimInspiralChooseWaveform(LALInferenceModel *model)
"XLALSimInspiralChooseWaveform{TD,FD}" wrapper.
void * XLALMalloc(size_t n)
void * XLALCalloc(size_t m, size_t n)
void XLALFree(void *p)
#define LAL_SIM_INSPIRAL_FRAME_AXIS_DEFAULT
SpinSupport
LALSimInspiralSpinOrder
LALSimInspiralFrameAxis
LALSimInspiralTidalOrder
Approximant
LALPNOrder
LAL_SIM_INSPIRAL_SINGLESPIN
LAL_SIM_INSPIRAL_SPINLESS
LAL_SIM_INSPIRAL_ALIGNEDSPIN
LAL_SIM_DOMAIN_TIME
LAL_SIM_DOMAIN_FREQUENCY
LAL_SIM_INSPIRAL_SPIN_ORDER_ALL
LAL_SIM_INSPIRAL_TIDAL_ORDER_ALL
NumApproximants
IMRPhenomP
IMRPhenomPv2_NRTidal
IMRPhenomD
IMRPhenomHM
IMRPhenomPv2
IMRPhenomPv2_NRTidalv2
TaylorF2
SEOBNRv4_ROM
IMRPhenomPv3HM
LALSimInspiralWaveformCache * XLALCreateSimInspiralWaveformCache(void)
LALValue * XLALSimInspiralModeArrayActivateMode(LALValue *modes, unsigned l, int m)
LALValue * XLALSimInspiralCreateModeArray(void)
LALSimNeutronStarEOS * XLALSimNeutronStarEOSByName(const char *name)
LALSimNeutronStarFamily * XLALCreateSimNeutronStarFamily(LALSimNeutronStarEOS *eos)
static const INT4 q
static const INT4 a
REAL8TimeSeries * XLALCreateREAL8TimeSeries(const CHAR *name, const LIGOTimeGPS *epoch, REAL8 f0, REAL8 deltaT, const LALUnit *sampleUnits, size_t length)
const LALUnit lalDimensionlessUnit
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
UINT4Vector * XLALCreateUINT4Vector(UINT4 length)
#define XLAL_ERROR_VOID(...)
const char * XLALErrorString(int errnum)
#define XLAL_ERROR_NULL(...)
#define XLAL_ERROR(...)
#define XLAL_CHECK_ABORT(assertion)
#define XLAL_TRY(statement, errnum)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
int int XLALPrintWarning(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
XLAL_SUCCESS
XLAL_EFAULT
XLAL_EINVAL
XLAL_FAILURE
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
help
type
Structure to contain IFO data.
Definition: LALInference.h:625
REAL8TimeSeries * timeData
Detector name.
Definition: LALInference.h:627
char name[DETNAMELEN]
Definition: LALInference.h:626
struct tagLALInferenceIFOData * next
ROQ data.
Definition: LALInference.h:659
REAL8 fLow
FFT plan needed for time/time-and-phase marginalisation.
Definition: LALInference.h:650
Structure to constain a model and its parameters.
Definition: LALInference.h:436
REAL8 * ifo_loglikelihoods
Network SNR at params
Definition: LALInference.h:445
REAL8 * ifo_SNRs
Array of single-IFO likelihoods at params
Definition: LALInference.h:446
REAL8FFTPlan * timeToFreqFFTPlan
Burst Waveform cache for LIB.
Definition: LALInference.h:460
COMPLEX16FrequencySeries * freqhPlus
Time series model buffers.
Definition: LALInference.h:454
LALSimNeutronStarFamily * eos_fam
Is ROQ enabled.
Definition: LALInference.h:465
REAL8 fHigh
Start frequency for waveform generation.
Definition: LALInference.h:449
REAL8TimeSeries * timehCross
Definition: LALInference.h:453
LALSimInspiralWaveformCache * waveformCache
Definition: LALInference.h:458
REAL8TimeSeries * timehPlus
Definition: LALInference.h:453
int roq_flag
ROQ data.
Definition: LALInference.h:464
LALInferenceVariables * params
Definition: LALInference.h:437
COMPLEX16FrequencySeries ** freqhs
Freq series model buffers.
Definition: LALInference.h:455
REAL8 deltaT
End frequency for waveform generation.
Definition: LALInference.h:450
COMPLEX16FrequencySeries * freqhCross
Definition: LALInference.h:454
LALDict * LALpars
Projected freq series model buffers.
Definition: LALInference.h:457
REAL8FFTPlan * freqToTimeFFTPlan
Definition: LALInference.h:460
REAL8Window * window
Pre-calculated FFT plans for forward and reverse FFTs.
Definition: LALInference.h:461
REAL8 fLow
Array of single-IFO SNRs at params
Definition: LALInference.h:448
LALInferenceTemplateFunction templt
Domain of model.
Definition: LALInference.h:440
LALSimulationDomain domain
IFO-dependent parameters and buffers.
Definition: LALInference.h:439
Structure containing inference run state This includes pointers to the function types required to run...
Definition: LALInference.h:592
ProcessParamsTable * commandLine
Definition: LALInference.h:593
LALInferenceVariables * proposalArgs
The data from the interferometers.
Definition: LALInference.h:602
INT4 nthreads
Array of live points for Nested Sampling.
Definition: LALInference.h:606
struct tagLALInferenceIFOData * data
Log sample, i.e.
Definition: LALInference.h:601
LALInferenceVariables * priorArgs
Common arguments needed by proposals, to be copied to thread->cycle.
Definition: LALInference.h:603
LALInferenceThreadState * threads
Definition: LALInference.h:612
LALInferencePriorFunction prior
The algorithm's single iteration function.
Definition: LALInference.h:597
LALInferenceLikelihoodFunction likelihood
MultiNest prior for the parameters.
Definition: LALInference.h:599
Structure containing chain-specific variables.
Definition: LALInference.h:541
REAL8 currentPrior
This should be removed, can be given as an algorithmParams or proposalParams entry.
Definition: LALInference.h:573
LALInferenceVariables * currentParams
Prior boundaries, etc.
Definition: LALInference.h:556
struct tagLALInferenceRunState * parent
Definition: LALInference.h:578
LALInferenceVariables * priorArgs
Stope things such as output arrays.
Definition: LALInference.h:553
LALInferenceModel * model
Cycle of proposals to call.
Definition: LALInference.h:548
REAL8 * currentIFOLikelihoods
Array storing single-IFO SNRs of current sample.
Definition: LALInference.h:569
LALInferenceVariables * proposalArgs
Definition: LALInference.h:551
The LALInferenceVariableItem list node structure This should only be accessed using the accessor func...
Definition: LALInference.h:154
char name[VARNAME_MAX]
Definition: LALInference.h:155
LALInferenceVariableType type
Definition: LALInference.h:157
LALInferenceParamVaryType vary
Definition: LALInference.h:158
The LALInferenceVariables structure to contain a set of parameters Implemented as a linked list of LA...
Definition: LALInference.h:170
CHAR value[LIGOMETA_VALUE_MAX]
REAL8Sequence * data
REAL8 * data
LIGOTimeGPS geocent_end_time
struct tagSimInspiralTable * next
CHAR waveform[LIGOMETA_WAVEFORM_MAX]
UINT4 * data
gsl_spline * amp_median
gsl_spline * phase_median
gsl_spline * amp_std
gsl_spline * phase_std
FILE * fp
double f_min
double f_max
double df
double srate