Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALInference 4.1.9.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LALInferenceCalibrationErrors.c
Go to the documentation of this file.
1/*
2 * LALInferenceCalibrationErrors.c: Bayesian Followup Calibration Errors routines.
3 *
4 * Copyright (C) 2014 Salvatore Vitale, Ryan Lynch
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#include <stdio.h>
23#include <lal/LALStdlib.h>
24#include <lal/FrequencySeries.h>
25#include <lal/Units.h>
26#include <lal/StringInput.h>
27#include <lal/TimeSeries.h>
28#include <lal/LALInference.h>
29#include <lal/LALDatatypes.h>
30#include <math.h>
31#include <lal/LALInferenceCalibrationErrors.h>
32#include <gsl/gsl_linalg.h>
33#include <gsl/gsl_blas.h>
34#include <gsl/gsl_rng.h>
35#include <gsl/gsl_randist.h>
36#include <lal/LALInferenceLikelihood.h>
37
38
39/* Hard coded fmin and fmax for CE calculation. Those should be large enough to accomodate any realistic CBC WF */
42/* Number of points to sample. Need to be an odd number */
44/* Order of the fit */
46// Use the value below to fill array 4th position of errors array to let the code know we want to use rnadom_linear errors. In the future might replace with a more robust way of doing it. For the moment this is a value which is impossible to obtain otherwise, thus it reliably convay the information
48
50static void fill_IFO_Amp_vars_from_IFOname(REAL8 * stddev,REAL8* fbin, char* ifoname);
51static void fill_IFO_Pha_vars_from_IFOname(REAL8 * stddev,REAL8* fbin, char* ifoname);
52static void CreateRandomAmplitudeCalibrationErrors(REAL8 * ampcoeffs, int calib_seed_ampli, char* ifoname);
53static void CreateRandomPhaseCalibrationErrors(REAL8 * phacoeffs, int calib_seed_pha, char* ifoname);
54static void FitErrorRealisation(INT4 R, INT4 N, REAL8 *y,REAL8 dlogf,REAL8 *D);
55static void InvertMatrixSVD (gsl_matrix *A,gsl_matrix *InvA, int N);
57static void ApplySquaredAmplitudeErrors(REAL8FrequencySeries * Spectrum,REAL8 * Acoeffs);
58static void ApplyBothPhaseAmplitudeErrors(COMPLEX16FrequencySeries *doff,REAL8 * Acoeffs,REAL8 * Pcoeffs);
61static void PrintCEtoFile(REAL8* Acoeffs,REAL8* Pcoeffs,LALInferenceIFOData* IFOdata, ProcessParamsTable *commandLine);
62static void fill_IFO_Amp_vars_from_IFOname(REAL8 * stddev,REAL8* fbin, char* ifoname){
63 /* The values below were typical values for the amplitude errors at the frequency bins ([0,2000] and [2000,4000] and >4000Hz in S5/S6*. Note 0.1==10% */
64 if (!strcmp(ifoname,"H1")){
65 stddev[0]=0.104;
66 stddev[1]=0.154;
67 stddev[2]=0.242;
68 fbin[1]=2000.0;
69 fbin[2]=4000.0;
70 }
71 else if(!strcmp(ifoname,"L1")){
72 stddev[0]=0.144;
73 stddev[1]=0.139;
74 stddev[2]=0.138;
75 fbin[1]=2000.0;
76 fbin[2]=4000.0;
77 }
78 else if(!strcmp(ifoname,"V1")){
79 stddev[0]=0.10;
80 stddev[1]=0.10;
81 stddev[2]=0.20;
82 fbin[1]=2000.0;
83 fbin[2]=4000.0;
84 }
85 else{
86 fprintf(stderr,"Unknown IFO in fill_IFO_vars_from_IFOname! Valid codes are H1, L1, V1. Aborting\n");
87 exit(-1);
88 }
89}
90
91void fill_IFO_Pha_vars_from_IFOname(REAL8 * stddev,REAL8* fbin, char* ifoname){
92 /* The values below were typical values for the phase errors at the frequency bins given below in the comments.
93 Errors here are in degrees. Will convert to rads in CreatePhaseCalibrationErrors */
94 if (!strcmp(ifoname,"H1")){
95 stddev[0]=4.5; // 1-500Hz
96 stddev[1]=4.5; // 500-1000Hz
97 stddev[2]=4.5; // 1k-2k
98 stddev[3]=4.9; // 2k -2.8k
99 stddev[4]=4.9; //2.8k-4k
100 stddev[5]=5.8;
101 fbin[1]=500.0;
102 fbin[2]=1000.0;
103 fbin[3]=2000.0;
104 fbin[4]=2800.0;
105 fbin[5]=4000.0;
106 }
107 else if(!strcmp(ifoname,"L1")){
108 stddev[0]=4.2; // 1-500
109 stddev[1]=4.2; // 500-1000
110 stddev[2]=4.2; // 1k-2k
111 stddev[3]=3.6; // 2k -2.8k
112 stddev[4]=3.6; //2.8k-4k
113 stddev[5]=3.3; // >4k
114 fbin[1]=500.0;
115 fbin[2]=1000.0;
116 fbin[3]=2000.0;
117 fbin[4]=2800.0;
118 fbin[5]=4000.0;
119 }
120 else if(!strcmp(ifoname,"V1")){
121 stddev[0]=2.2918; // 1-500
122 stddev[1]=0.5729; // 500-1000
123 stddev[2]=6.87; // 1k-2k
124 stddev[3]=6.87; // 2k -2.8k
125 stddev[4]=360.0*7e-06; //2.8k-4k
126 stddev[5]=360.0*7e-06; // >4k
127 fbin[1]=500.0;
128 fbin[2]=1000.0;
129 fbin[3]=2000.0;
130 fbin[4]=2800.0;
131 fbin[5]=4000.0;
132 }
133 else{
134 fprintf(stderr,"Unknown IFO in fill_IFO_Pha_vars_from_IFOname! Valid codes are H1, L1, V1. Aborting\n");
135 exit(-1);
136 }
137 }
138
139/**
140 * Parse the calibration command line looking for options of the kind ---IFO-option value
141 * Unlike the correnspoding option in ReadData, this one does not have a preset list of names to lookup, but instead uses the option "name"
142 * It is necessary to use this method instead of the old method for the pipeline to work in DAX mode. Warning: do not mix options between
143 * the old and new style.
144 */
145static INT4 getNamedDataOptionsByDetectors(ProcessParamsTable *commandLine, char ***ifos, char ***out, const char *name, UINT4 *N)
146{
147 /* Check that the input has no lists with [ifo,ifo] */
148 ProcessParamsTable *this=commandLine;
149 UINT4 i=0;
150 *out=*ifos=NULL;
151 *N=0;
152 char tmp[128];
153 if(!this) {fprintf(stderr,"No command line arguments given!\n"); exit(1);}
154 /* Construct a list of IFOs */
155 for(this=commandLine;this;this=this->next)
156 {
157 if(!strcmp(this->param,"--ifo"))
158 {
159 (*N)++;
160 *ifos=XLALRealloc(*ifos,*N*sizeof(char *));
161 (*ifos)[*N-1]=XLALStringDuplicate(this->value);
162 }
163 }
164 *out=XLALCalloc(*N,sizeof(char *));
165
166 UINT4 found=0;
167 /* For each IFO, fetch the other options if available */
168 for(i=0;i<*N;i++)
169 {
170 /* Channel */
171 sprintf(tmp,"--%s-%s",(*ifos)[i],name);
172 this=LALInferenceGetProcParamVal(commandLine,tmp);
173 (*out)[i]=this?XLALStringDuplicate(this->value):NULL;
174 if (this) found++;
175
176 }
177 if (found==*N)
178 return(1);
179 else
180 return 0;
181}
182
183
184void CreateRandomAmplitudeCalibrationErrors(REAL8 * ampcoeffs, int calib_seed_ampli, char* ifoname){
185
186 /* GSL generator */
187 const gsl_rng_type *type; // RNG type
188 gsl_rng *p; // Generator
189 gsl_rng_env_setup(); // Setup environment
190 gsl_rng_default_seed = calib_seed_ampli; // vary generation sequence
191 type = gsl_rng_default; // set RNG type to default
192 p = gsl_rng_alloc (type);
193 int i,j;
194 REAL8 ampErr[Npoints];
195
196 /* 3 as Amplitude CE are given in three frequency bins */
197 REAL8 amp_stdev[3]={0.0};
198
199 /* The stdevs are the errors in the bins [freq_min,freq[bin][0]],[freq[bin][1],freq[bin][2]],.., [freq[bin][last],freq_max]. In Hertz */
200 /* plus 2 to accomodate freq_min and freq_max in the first/last position */
201 REAL8 amp_freq_bin[2+2]={0.0};
202 amp_freq_bin[0]=freq_min;
203 amp_freq_bin[3]=freq_max;
204
205 fill_IFO_Amp_vars_from_IFOname(amp_stdev,amp_freq_bin,ifoname);
206
207 /* Space frequencies uniformly in logF */
208 REAL8 logF[Npoints];
209 REAL8 deltalogf=(log10(freq_max)-log10(freq_min))/(REAL8)(Npoints-1);
210 for (i=0; i<Npoints; i++) {
211 logF[i]=log10(freq_min)+deltalogf*i;
212 }
213 int nbins=3;
214 /* draw amplitude errors */
215 for (i=0; i<Npoints; i++) {
216 for(j=0;j<nbins;j++){
217 if (logF[i]>=log10(amp_freq_bin[j]) && logF[i]<=log10(amp_freq_bin[j+1])) {
218 ampErr[i]=gsl_ran_gaussian(p, amp_stdev[j]);
219 }
220 }
221 }
222
223 FitErrorRealisation(FitOrder,Npoints,ampErr,deltalogf,ampcoeffs);
224 free(p);
225}
226
227void CreateRandomPhaseCalibrationErrors(REAL8 * phacoeffs, int calib_seed_pha, char* ifoname){
228
229 /* GSL generator */
230 const gsl_rng_type *type; // RNG type
231 gsl_rng *p; // Generator
232 gsl_rng_env_setup(); // Setup environment
233 gsl_rng_default_seed = calib_seed_pha; // vary generation sequence
234 type = gsl_rng_default; // set RNG type to default
235 p = gsl_rng_alloc (type);
236 int i,j;
237 REAL8 phaErr[Npoints];
238 /* 6 as Phase CE are given in six frequency bins */
239 REAL8 pha_stdev[6]={0.0};
240 /* The stdevs are the errors in the bins [freq_min,freq[bin][0]],[freq[bin][1],freq[bin][2]],.., [freq[bin][last],freq_max]. In Hertz */
241 /* plus 2 to accomodate freq_min and freq_max in the first/last position */
242 REAL8 pha_freq_bin[5+2]={0.0};
243
244 pha_freq_bin[0]=freq_min;
245 pha_freq_bin[6]=freq_max;
246
247 fill_IFO_Pha_vars_from_IFOname(pha_stdev,pha_freq_bin,ifoname);
248 /* Space frequencies uniformly in logF */
249 REAL8 logF[Npoints];
250 REAL8 deltalogf=(log10(freq_max)-log10(freq_min))/(REAL8)(Npoints-1);
251 for (i=0; i<Npoints; i++) {
252 logF[i]=log10(freq_min)+deltalogf*i;
253 }
254
255 int nbins=6;
256 /* draw phase errors */
257 for (i=0; i<Npoints; i++) {
258 for(j=0;j<nbins;j++){
259 if (logF[i]>=log10(pha_freq_bin[j]) && logF[i]<=log10(pha_freq_bin[j+1])) {
260 phaErr[i]=gsl_ran_gaussian(p, pha_stdev[j]);
261 phaErr[i]*=LAL_PI/180.0;
262 }
263 }
264 }
265
266 FitErrorRealisation(FitOrder,Npoints,phaErr,deltalogf,phacoeffs);
267 free(p);
268}
269
271 /* Take a Complex16FrequencySeries d(f) and a set of phase error coefficients.
272 * Return d(f)*exp(I calpha(f))*/
273
274 REAL8 f=0.0;
275 /* Amplitude and phase of the WF (in polar coordinates) */
276 REAL8 ampli,phase=0.0;
277 COMPLEX16 datum;
278 REAL8 df=doff->deltaF;
279 UINT4 ui;
280 for (ui=0;ui<doff->data->length;ui++){
281 f=ui*df;
282 datum=doff->data->data[ui];
283 ampli=sqrt(creal(datum)*creal(datum)+cimag(datum)*cimag(datum));
284 phase=atan2(cimag(datum),creal(datum));
285
286 if (Pcoeffs[Npoints+3]==random_linearCE_bit)
287 phase+=ConvertRandTransitionSlopeToFunction(Pcoeffs,f);
288 else //catch all random errors
289 phase+=ConvertCoefficientsToFunction(Pcoeffs,f);
290 doff->data->data[ui]=crect(ampli*cos(phase),ampli*sin(phase));
291 /* Note: I (salvo) checked that this way of introducing the phase errors does not introduced significant numerical differences w.r.t. expanding both exp(i cE) and datum in their real and imag part, as done in the commented line below and in the likelihood. */
292 //doff->data->data[ui]=crect(creal(datum)*cos(tmp)-cimag(datum)*sin(tmp),cos(tmp)*cimag(datum)+sin(tmp)*creal(datum));
293 }
294
295}
296
298 /* Take a Complex16FrequencySeries d(f) and a set of amplitude error coefficients.
299 * Return d(f)*calamp(f) */
300 REAL8 f=0.0;
301 /* Amplitude and phase of the WF (in polar coordinates) */
302 REAL8 ampli;
303 COMPLEX16 datum;
304 REAL8 df=doff->deltaF;
305 UINT4 ui;
306 for (ui=0;ui<doff->data->length;ui++){
307 f=ui*df;
308 datum=doff->data->data[ui];
309
310 if (Acoeffs[Npoints+3]==random_linearCE_bit)
311 ampli= 1. + ConvertRandTransitionSlopeToFunction(Acoeffs,f);
312 else
313 ampli= 1. + ConvertCoefficientsToFunction(Acoeffs,f);
314
315 doff->data->data[ui]=crect(creal(datum)*ampli,cimag(datum)*ampli);
316 }
317}
318
320 /* Apply both phase and amplitude errors to complex 16 stream */
322 ApplyPhaseCalibrationErrors(doff,Pcoeffs);
323}
324
326 /* Take a REAL8Frequency series S(f) and a set of amplitude error coefficients.
327 * Return S(f)*calamp(f)*calamp(f) */
328 REAL8 f=0.0;
329 REAL8 ampli;
330 REAL8 df=Spectrum->deltaF;
331 UINT4 ui;
332 for (ui=0;ui<Spectrum->data->length;ui++){
333 f=ui*df;
334 if (Acoeffs[Npoints+3]==random_linearCE_bit)
335 ampli= 1.+ConvertRandTransitionSlopeToFunction(Acoeffs,f);
336 else
337 ampli= 1. + ConvertCoefficientsToFunction(Acoeffs,f);
338
339 Spectrum->data->data[ui]*=(ampli*ampli);
340 }
341}
342
344 /*
345 * This function takes a pointer to a linked list of IFO data and applies calibration errors to data->freqData (i.e. the frequency domain stream),
346 * data->oneSidedNoisePowerSpectrum (i.e. the PSD) and data->freqData. These arrays must already have been filled by LALInferenceReadData() and
347 * (if injtable is used) by LALInferenceInjectInspiralSignal(). CE are either randomly generated or constant.
348 */
349 char help[]="\
350\n\
351------------------------------------------------------------------------------------------------------------------\n\
352--- Calibration Errors Handling Arguments ------------------------------------------------------------------------\n\
353------------------------------------------------------------------------------------------------------------------\n\
354(--AddCalibrationErrors) Adds calibration errors into the f domain datastream (that includes both noise and signal)\n\
355(--RandomCE) Add a random realization of phase and amplitude CE, using the S6/VSR2-3 error budget as an indication of the 1-sigma errors\n\
356(--ConstantCE) Assumes calibration errors are constant over the bandwidth (requires --IFO-constant_calamp and --IFO-constant_calpha for each ifo)\n\
357(--IFO-constant_calamp Constant amplitude CE for instrument IFO. 0.0 means no error, 0.1 means 10 percent\n\
358(--IFO-constant_calpha Constant phase CE for instrument IFO. 0.0 means no error, 5 means a 5 degree shift \n\
359(--RandomLinearCE ) Assumes CE are given by a contant plateau plus a random jittering of a few percent.\n\t\t After a given frequency f CE increase linearly with a given slope (requires --IFO-calamp_plateau, --IFO-calamp_knee, --IFO-calamp_slope AND similar with calamp<->calpha. Phase Errors in degree, Amp errors are relative (0.05=5%) \n\
360(--IFO-calamp_plateau, --IFO-calamp_knee, --IFO-calamp_slope) Add on the i-th IFO's stream amplitude errors on the form (IFOi_c + jitter) for f<IFOi_f and (IFOi_c-f)*IFOi_slope for f>IFOi_f\n\
361(--IFO-calpha_plateau, --IFO-calpha_knee, --IFO-calpha_slope) Add on the i-th IFO's stream phase errors on the form (IFOi_c + jitter) for f<IFOi_f and (IFOi_c-f)*IFOi_slope for f>IFOi_f\n\
362 * Constant Calibration Model \n\
363 (--MarginalizeConstantCalAmp ) If given, will add a constant value of Amplitude CE per each IFO on the top of the CBC parameters.\n\
364 (--MarginalizeConstantCalPha ) If given, will add a constant value of Phase CE per each IFO on the top of the CBC parameters.\n\
365 (--constcal_ampsigma ) If given, will use gaussian prior on the constant amplitude error with this sigma (e.g. 0.05=5%) .\n\
366 (--constcal_phasigma ) If given, will use gaussian prior on the constant phase error with this sigma (e.g. 5=5degs).\n\
367 * Spline Calibration Model \n\
368 (--enable-spline-calibration) Enable cubic-spline calibration error model.\n\
369 (--spcal-nodes N) Set the number of spline nodes per detector (default 5)\n\
370 (--IFO-spcal-amp-uncertainty X) Set the prior on relative amplitude uncertainty for the instrument IFO (mandatory with --enable-spline-calibration)\n\
371 (--IFO-spcal-phase-uncertainty X) Set the prior on phase uncertanity in degrees for the instrument IFO (mandatory with --enable-spline-calibration)\n\
372 (--IFO-spcal-envelope F) Read amplitude and phase calibration uncertainty envelope from file F\n\n\n";
373
374 static LALStatus status;
375 /* Print command line arguments if help requested */
376 if(LALInferenceGetProcParamVal(commandLine,"--help"))
377 {
378 fprintf(stdout,"%s",help);
379 return;
380 }
381
382 //ProcessParamsTable *ppt=NULL;
383
384 if(!LALInferenceGetProcParamVal(commandLine,"--AddCalibrationErrors"))
385 {
386 fprintf(stdout,"No --AddCalibrationErrors option given. Not applying calibration errors in injection...\n");
387 return;
388 }
389
390 /* Set calibration seed for random errors */
391 if(!LALInferenceGetProcParamVal(commandLine,"--dataseed")){
392 fprintf(stdout,"--dataseed is required when running with --AddCalibrationErrors\n");
393 exit(1);
394 }
395 int dataseed=atoi(LALInferenceGetProcParamVal(commandLine,"--dataseed")->value);
396 RandomParams *datarandparam=XLALCreateRandomParams(dataseed);
397
398 int calib_seed_ampli=0.0;
399 int calib_seed_phase=0.0;
400 REAL4 tmpampli,tmpphase;
401 LALUniformDeviate(&status,&tmpampli,datarandparam);
402 LALUniformDeviate(&status,&tmpphase,datarandparam);
403 calib_seed_ampli=floor(1E6*tmpampli);
404 calib_seed_phase=floor(1E6*tmpphase);
405 fprintf(stdout,"Using calibseedAmp %d and calibseedPha %d\n",calib_seed_ampli,calib_seed_phase);
406
407 LALInferenceIFOData * tmpdata=IFOdata;
408 int num_ifos=0;
409 int i;
410 //UINT4 unum_ifos=(UINT4) num_ifos;
411
412 while (tmpdata!=NULL) {
413 num_ifos++;
414 tmpdata=tmpdata->next;
415 }
416 tmpdata=IFOdata;
417 int this_ifo=0;
418 REAL8 phaseCoeffs[num_ifos][Npoints*2];
419 REAL8 ampCoeffs[num_ifos][Npoints*2];
420 while (tmpdata!=NULL) {
421 memset(ampCoeffs[this_ifo],0.0,2*Npoints*sizeof(REAL8));
422 memset(phaseCoeffs[this_ifo],0.0,2*Npoints*sizeof(REAL8));
423 this_ifo++;
424 tmpdata=tmpdata->next;
425 }
426 if(LALInferenceGetProcParamVal(commandLine,"--RandomCE")){
427 /* Random phase and amplitude calibration errors. Use S6 Budget. That is an overkill, but may be good to test worst case scenarios. */
428 fprintf(stdout,"Applying random phase and amplitude errors. \n");
429 tmpdata=IFOdata;
430 this_ifo=0;
431 /* For each IFO create a CE realization and write in amp/phaseCoeffs the coefficients of the polynomial expansion */
432 while (tmpdata!=NULL){
433 CreateRandomAmplitudeCalibrationErrors(ampCoeffs[this_ifo],calib_seed_ampli,tmpdata->name);
434 CreateRandomPhaseCalibrationErrors(phaseCoeffs[this_ifo],calib_seed_phase,tmpdata->name);
435 LALUniformDeviate(&status,&tmpampli,datarandparam);
436 LALUniformDeviate(&status,&tmpphase,datarandparam);
437 calib_seed_ampli+=floor(1E6*tmpampli);
438 calib_seed_phase+=floor(1E6*tmpphase);
439 this_ifo++;
440 tmpdata=tmpdata->next;
441 }
442 }
443 else if (LALInferenceGetProcParamVal(commandLine,"--ConstantCE")){
444 /* NOTE: If we want to apply constant CE we simply have to set ampCoeffs and phaseCoeffs in such a way that the 0th element is non null, while the others are zero. */
445
446 char **plateau=NULL;
447 char plateau_option[] = "constant_calamp";
448 char **pplateau=NULL;
449 char pplateau_option[] = "constant_calpha";
450 char **IFOnames=NULL;
451 UINT4 Nifo;
452 INT4 rlceops= getNamedDataOptionsByDetectors(commandLine, &IFOnames,&plateau ,plateau_option, &Nifo);
453 if (!rlceops){
454 fprintf(stderr,"Must provide a --IFO-constant_calamp option for each IFO if --ConstantCE is given\n");
455 exit(1);
456 }
457 fprintf(stdout,"Applying constant amplitude calibration errors. \n");
458 rlceops= getNamedDataOptionsByDetectors(commandLine, &IFOnames,&pplateau ,pplateau_option, &Nifo);
459 if (!rlceops){
460 fprintf(stderr,"Must provide a --IFO-constant_calpha option for each IFO if --ConstantCE is given\n");
461 exit(1);
462 }
463 fprintf(stdout,"Applying constant phase calibration errors. \n");
464 for(i=0;i<num_ifos;i++){
465 (ampCoeffs[i])[0]=atof(plateau[i]);
466 (phaseCoeffs[i])[0]=atof(pplateau[i])*LAL_PI/180.0;
467 }
468 for(i=0;i<num_ifos;i++) {
469 if(plateau) if (plateau[i]) XLALFree(plateau[i]);
470 if(pplateau) if (pplateau[i]) XLALFree(pplateau[i]);
471 }
472 }
473 else if (LALInferenceGetProcParamVal(commandLine,"--RandomLinearCE")){
474 char **plateau=NULL;
475 char plateau_option[] = "calamp_plateau";
476 char **knee=NULL;
477 char knee_option[] = "calamp_knee";
478 char **slope=NULL;
479 char slope_option[] = "calamp_slope";
480 char **IFOnames=NULL;
481 UINT4 Nifo;
482 INT4 rlceops= getNamedDataOptionsByDetectors(commandLine, &IFOnames,&plateau ,plateau_option, &Nifo);
483 if (!rlceops){
484 fprintf(stderr,"Must provide a --IFO-calamp_plateau option for each IFO if --RandomLinearCE is given\n");
485 exit(1);
486 }
487 rlceops= getNamedDataOptionsByDetectors(commandLine, &IFOnames,&knee ,knee_option, &Nifo);
488 if (!rlceops){
489 fprintf(stderr,"Must provide a --IFO-calamp_knee option for each IFO if --RandomLinearCE is given\n");
490 exit(1);
491 }
492 rlceops= getNamedDataOptionsByDetectors(commandLine, &IFOnames,&slope ,slope_option, &Nifo);
493 if (!rlceops){
494 fprintf(stderr,"Must provide a --IFO-calamp_slope option for each IFO if --RandomLinearCE is given\n");
495 exit(1);
496 }
497
498 fprintf(stdout,"Applying quasi constant amplitude calibration errors. \n");
499 i=0;
500 tmpdata=IFOdata;
501 while (tmpdata!=NULL){
502 /* Store variables for random jitter in the first (Npoints-1) positions of ampCoeffs.
503 * Store constant plateau, knee position and slope in the next 3 positions.
504 * Store random_linearCE_bit (-300) in the last position to make the code recognize our choice */
505
506 /* Fill random part. Will take 10% of it later on */
507 CreateRandomAmplitudeCalibrationErrors(ampCoeffs[i],calib_seed_ampli,tmpdata->name);
508 LALUniformDeviate(&status,&tmpampli,datarandparam);
509 calib_seed_ampli+=floor(1E6*tmpampli);
510 /* Consant plateau, knee, slope*/
511 (ampCoeffs[i])[Npoints]=atof(plateau[i]);
512 (ampCoeffs[i])[Npoints+1]=atof(knee[i]);
513 (ampCoeffs[i])[Npoints+2]=atof(slope[i]);
514 (ampCoeffs[i])[Npoints+3]=random_linearCE_bit;
515 i++;
516 tmpdata=tmpdata->next;
517 }
518 for(i=0;i<num_ifos;i++) {
519 if(plateau) if (plateau[i]) XLALFree(plateau[i]);
520 if(knee) if (knee[i]) XLALFree(knee[i]);
521 if(slope) if (slope[i]) XLALFree(slope[i]);
522 }
523
524 char **pplateau=NULL;
525 char pplateau_option[] = "calpha_plateau";
526 char **pknee=NULL;
527 char pknee_option[] = "calpha_knee";
528 char **pslope=NULL;
529 char pslope_option[] = "calpha_slope";
530
531 rlceops= getNamedDataOptionsByDetectors(commandLine, &IFOnames,&pplateau ,pplateau_option, &Nifo);
532 if (!rlceops){
533 fprintf(stderr,"Must provide a --IFO-calpha_plateau option for each IFO if --RandomLinearCE is given\n");
534 exit(1);
535 }
536 rlceops= getNamedDataOptionsByDetectors(commandLine, &IFOnames,&pknee ,pknee_option, &Nifo);
537 if (!rlceops){
538 fprintf(stderr,"Must provide a --IFO-calpha_knee option for each IFO if --RandomLinearCE is given\n");
539 exit(1);
540 }
541 rlceops= getNamedDataOptionsByDetectors(commandLine, &IFOnames,&pslope ,pslope_option, &Nifo);
542 if (!rlceops){
543 fprintf(stderr,"Must provide a --IFO-calpha_slope option for each IFO if --RandomLinearCE is given\n");
544 exit(1);
545 }
546
547 fprintf(stdout,"Applying quasi constant phase calibration errors. \n");
548
549 i=0;
550 tmpdata=IFOdata;
551 while (tmpdata!=NULL){
552 /* Store variables for random jitter in the first (Npoints-1) positions of phaCoeffs.
553 * Store constant plateau, knee position and slope in the next 3 positions.
554 * Store random_linearCE_bit (-300) in the last position to make the code recognize our choice */
555
556 /* Fill random part. Will take 10% of it later on */
557 CreateRandomPhaseCalibrationErrors(phaseCoeffs[i],calib_seed_phase,tmpdata->name);
558
559 LALUniformDeviate(&status,&tmpphase,datarandparam);
560 calib_seed_phase+=floor(1E6*tmpphase);
561 /* Consant plateau, knee, slope*/
562 // user gave degrees, convert to radiands
563 (phaseCoeffs[i])[Npoints]=LAL_PI/180.*atof(pplateau[i]);
564 // transition frequency (Hz)
565 (phaseCoeffs[i])[Npoints+1]=atof(pknee[i]);
566 // slope. After the transition freq the errors go like f^slope
567 (phaseCoeffs[i])[Npoints+2]=atof(pslope[i]);
568 (phaseCoeffs[i])[Npoints+3]=random_linearCE_bit;
569 i++;
570 tmpdata=tmpdata->next;
571 }
572 for(i=0;i<num_ifos;i++) {
573 if(pplateau) if (pplateau[i]) XLALFree(pplateau[i]);
574 if(pknee) if (pknee[i]) XLALFree(pknee[i]);
575 if(pslope) if (pslope[i]) XLALFree(pslope[i]);
576 }
577 }
578 else{
579 fprintf(stderr, "Must provide a calibration error flag together with --AddCalibrationErrors\n");
580 exit(1);
581 }
582 /* Now apply CE to various quantities */
583 tmpdata=IFOdata;
584 this_ifo=0;
585 while (tmpdata!=NULL){
586 PrintCEtoFile(ampCoeffs[this_ifo],phaseCoeffs[this_ifo],tmpdata, commandLine);
587 ApplyBothPhaseAmplitudeErrors(tmpdata->freqData,ampCoeffs[this_ifo],phaseCoeffs[this_ifo]);
588 ApplyPhaseCalibrationErrors(tmpdata->whiteFreqData,phaseCoeffs[this_ifo]);
589 ApplySquaredAmplitudeErrors(tmpdata->oneSidedNoisePowerSpectrum,ampCoeffs[this_ifo]);
590 this_ifo++;
591 tmpdata=tmpdata->next;
592 }
593 XLALDestroyRandomParams(datarandparam);
594}
595
596void PrintCEtoFile(REAL8* Acoeffs,REAL8* Pcoeffs,LALInferenceIFOData* IFOdata, ProcessParamsTable *commandLine ){
597
598 REAL8 f=0.0;
599 UINT4 ui;
600 REAL8 df=IFOdata->freqData->deltaF;
601 UINT4 f_low_idx=ceil( IFOdata->fLow/df);
602 UINT4 f_high_idx=floor(IFOdata->fHigh/df);
603 if (df*f_low_idx<freq_min || df*f_high_idx >freq_max) {
604 fprintf(stderr,"The min and max frequency in LALInspiralCalibrationErrors.c are inside the range [flow,fmin] of the integral overlap. Exiting...\n");
605 exit(1);
606 }
607
608 ProcessParamsTable *ppt_order=NULL;
609 ppt_order=LALInferenceGetProcParamVal(commandLine, "--outfile");
610 char *outfile=ppt_order->value;
611
612 FILE *calibout;
613 char caliboutname[2048];
614 sprintf(caliboutname,"%s_CE_%s.dat",outfile, IFOdata->name);
615 calibout=fopen(caliboutname,"w");
616
617 for(ui=f_low_idx;ui<f_high_idx;ui++){
618 f=ui*df;
619 if (Acoeffs[3+Npoints]==random_linearCE_bit)
620 fprintf(calibout,"%lf \t%10.10e \t%10.10e\n",f,ConvertRandTransitionSlopeToFunction(Acoeffs,f),ConvertRandTransitionSlopeToFunction(Pcoeffs,f));
621 else
622 fprintf(calibout,"%lf \t%10.10e \t%10.10e\n",f,ConvertCoefficientsToFunction(Acoeffs,f),ConvertCoefficientsToFunction(Pcoeffs,f));
623 }
624 fclose(calibout);
625}
626
628{
629
630 int i=0; int j=0;
631 /*********************************************************************
632 *
633 * Savitsky-Golay Filter
634 * - Based on least square fitting of a polynomial of Rth order
635 * - Smoothens function by extrapolating from m neighbouring points
636 * - See Abraham Savitsky and Marcel J. E. Golay
637 * "Smoothing and differentiation of data by simplified least squares procedures"
638 *
639 ********************************************************************/
640
641 /*********************************************************************
642 *
643 * LAL error handling
644 *
645 *********************************************************************/
646
647 //INITSTATUS( status, "LALSavitskyGolayFilter", LALCALIBRATIONERRORSC);
648 //ATTATCHSTATUSPTR(status);
649
650 /*********************************************************************
651 *
652 * Read input
653 *
654 *********************************************************************/
655
656 /* LOAD IN TIMESERIES PARAMETERS */
657 INT4 M = (N-1)/2;
658 //printf("Input parameters: R = %d | M = %d | N = %d | dt = %e \n", R, M, N, dt);
659
660 /*********************************************************************
661 *
662 * Create Temporary Variables
663 *
664 ********************************************************************/
665
666 //printf("Initialising Variables \n");
667
668 /* COUNTERS */
669 int k;
670
671 /* factorial of D (used for derivatives) */
672 INT4 factorial = 1;
673
674 /* MATRICES AND VECTORS */
675 gsl_matrix *m = gsl_matrix_calloc (R+1, 2*M+1); /* m_ij = j^i */
676 gsl_matrix *U = gsl_matrix_calloc (R+1, R+1); /* U_ii = deltaT^i */
677 gsl_vector *a = gsl_vector_calloc (R+1); /* a_j, for y(t_i) = Sum_{j=0}^{R} a_j t_i^j */
678 gsl_matrix *c = gsl_matrix_calloc (R+1, 2*M+1); /* c_ij = U_-1 (m m^T)^-1 m, in a_j = c_ji y_i */
679 gsl_vector *ym = gsl_vector_calloc (2*M+1); /* y_m = [y_-M, ... , y_M] */
680 gsl_matrix *tmr = gsl_matrix_calloc (R+1, 2*M+1); /* t_m^r = U*m */
681
682 /* COMBINED MATRICES AND VECTORS */
683 gsl_matrix *mT = gsl_matrix_calloc (2*M+1, R+1); /* m^T */
684 gsl_matrix *mmT = gsl_matrix_calloc (R+1, R+1); /* mm^T */
685 gsl_matrix *InvmmT = gsl_matrix_calloc (R+1, R+1); /* (mm^T)^-1 */
686 gsl_matrix *InvmmTm = gsl_matrix_calloc (R+1, 2*M+1); /* (mm^T)^-1 m */
687 gsl_matrix *InvU = gsl_matrix_calloc (R+1, R+1); /* U^-1 */
688
689 /*********************************************************************
690 *
691 * Filling matrices
692 *
693 ********************************************************************/
694 //printf("Filling parameters \n");
695
696 /* m_ij = j^i */
697 //printf("Filling parameters - m %dx%d\n", m->size1, m->size2);
698 for(i=0;i<(R+1);i++)
699 {
700 for(j=0;j<(2*M+1);j++)
701 {
702 gsl_matrix_set(m, i, j, pow((j-M), i));
703 }
704 }
705
706 //printf("m %dx%d\n", m->size1, m->size2);
707 //for(i=0;i<((R+1)*(2*M+1));i++)
708 //{
709 //printf("%e", gsl_matrix_get(m, i/(2*M+1), i%(2*M+1)));
710 //if(i%(2*M+1)==(2*M)) printf("\n");
711 //else printf("\t");
712 //}
713 //printf("\n");
714
715 /* U_ii = deltaT^i */
716 //printf("Filling parameters - U %dx%d \n", U->size1, U->size2);
717 for(i=0;i<(R+1);i++)
718 {
719 gsl_matrix_set(U, i, i, pow(dlogf,i));
720 }
721
722 //printf("U %dx%d\n", U->size1, U->size2);
723 //for(i=0;i<((R+1)*(R+1));i++)
724 //{
725 //printf("%e", gsl_matrix_get(U, i/(R+1), i%(R+1)));
726 //if(i%(R+1)==(R)) printf("\n");
727 //else printf("\t");
728 //}
729 //printf("\n");
730
731 /* m^T */
732 //printf("Filling parameters - mT %dx%d\n", mT->size1, mT->size2);
733 for(i=0;i<(R+1); i++)
734 {
735 for(j=0;j<(2*M+1);j++)
736 {
737 gsl_matrix_set(mT, j, i, gsl_matrix_get(m, i, j));
738 }
739 }
740
741 //printf("mT %dx%d\n", mT->size1, mT->size2);
742 //for(i=0;i<((2*M+1)*(R+1));i++)
743 //{
744 //printf("%e", gsl_matrix_get(mT, i/(R+1), i%(R+1)));
745 //if(i%(R+1)==(R)) printf("\n");
746 //else printf("\t");
747 //}
748 //printf("\n");
749
750 /* mm^T */
751 //printf("Filling parameters - mmT %dx%d\n", mmT->size1, mmT->size2);
752 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
753 1.0, m, mT,
754 0.0, mmT);
755
756 //printf("mmT %dx%d\n", mmT->size1, mmT->size2);
757 //for(i=0;i<((R+1)*(R+1));i++)
758 //{
759 //printf("%e", gsl_matrix_get(mmT, i/(R+1), i%(R+1)));
760 //if(i%(R+1)==(R)) printf("\n");
761 //else printf("\t");
762 //}
763 //printf("\n");
764
765 /* (mm^T)^-1 */
766 //printf("Filling parameters - InvmmT %dx%d\n", InvmmT->size1, InvmmT->size2);
767 InvertMatrixSVD(mmT, InvmmT, R+1);
768
769 /* U^-1*/
770 //printf("Filling parameters - InvU %dx%d\n", InvU->size1, InvU->size2);
771 //InvertMatrixSVD(U, InvU, R+1);
772
773 for(i=0;i<(R+1);i++)
774 {
775 //printf("%e | %e \n", 1.0/gsl_matrix_get(U, i, i), gsl_matrix_get(InvU, i, i));
776 gsl_matrix_set(InvU, i, i, 1.0/gsl_matrix_get(U, i, i));
777 }
778
779 /* (mm^T)^-1 m */
780 //printf("Filling parameters - InvmmTm %dx%d \n", InvmmTm->size1, InvmmTm->size2 );
781 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
782 1.0, InvmmT, m,
783 0.0, InvmmTm);
784
785 //printf("InvmmTm \n");
786 //for(i=0;i<((R+1)*(2*M+1));i++)
787 //{
788 //printf("%e", gsl_matrix_get(InvmmTm, i/(2*M+1), i%(2*M+1)));
789 //if(i%(2*M+1)==(2*M)) printf("\n");
790 //else printf("\t");
791 //}
792 //printf("\n");
793
794 /* c_ij = U_-1 (m m^T)^-1 m */
795 //printf("Filling parameters - c \n");
796 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
797 1.0, InvU, InvmmTm,
798 0.0, c);
799
800 //printf("c \n");
801 //for(i=0;i<((c->size1)*(c->size2));i++)
802 //{
803 //printf("%e", gsl_matrix_get(c, i/(c->size2), i%(c->size2)));
804 //if(i%(c->size2)==(c->size2-1)) printf("\n");
805 //else printf("\t");
806 //}
807 //printf("\n");
808
809 /* t_m^r = U*m */
810 //printf("%dx%d -> (%dx%d)x(%dx%d)\n", tmr->size1, tmr->size2, U->size1, U->size2, m->size1, m->size2);
811 //printf("Filling parameters - tmr \n");
812 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
813 1.0, U, m,
814 0.0, tmr);
815
816
817 /*********************************************************************
818 *
819 * Set polynomial prefactors and smooth function
820 *
821 ********************************************************************/
822
823 //printf("Smoothing \n");
824 /* READ DATA POINTS INTO VECTOR */
825 for(j=0;j<2*M+1;j++)
826 {
827 gsl_vector_set(ym, j, y[j]);
828 }
829
830 /* a = c*y */
831 gsl_blas_dgemv( CblasNoTrans,
832 1.0, c, ym,
833 0.0, a );
834
835 for(k=0; k<R; k++)
836 {
837 D[k] = factorial*gsl_vector_get(a, k);
838 }
839
840 gsl_vector_set_zero (ym);
841 gsl_vector_set_zero (a);
842
843 /*********************************************************************
844 *
845 * Output to file
846 *
847 ********************************************************************/
848 //printf("Write to file \n");
849 //FILE *smoothOut;
850 //smoothOut = fopen("smoothOut.dat", "w");
851
852 //for(k=0;k<N;k++)
853 //{
854 //fprintf(smoothOut, "%e\t%e\n", k*dt, Output[k]);
855 //}
856 //fclose(smoothOut);
857
858 /*********************************************************************
859 *
860 * Clean Up
861 *
862 ********************************************************************/
863
864 //printf("Cleaning up \n");
865 gsl_matrix_free(m);
866 gsl_matrix_free(U);
867 gsl_vector_free(a);
868 gsl_matrix_free(c);
869 gsl_vector_free(ym);
870 gsl_matrix_free(tmr);
871 gsl_matrix_free(mT);
872 gsl_matrix_free(mmT);
873 gsl_matrix_free(InvmmT);
874 gsl_matrix_free(InvmmTm);
875 gsl_matrix_free(InvU);
876
877 //DETATCHSTATUSPTR(status);
878 //RETURN(status);
879}
880
881void InvertMatrixSVD (gsl_matrix *A,gsl_matrix *InvA, int N)
882{
883
884 /*********************************************************************
885 *
886 * CREATING TEMPORARY VARIABLES
887 *
888 ********************************************************************/
889 int i=0;
890 // Initialise matrices A, U, S and V
891 gsl_matrix *InvS = gsl_matrix_calloc (N, N); // inverse S
892 gsl_matrix *V = gsl_matrix_calloc (N, N); // V
893 gsl_matrix *U = gsl_matrix_calloc (N, N); // U
894 gsl_matrix *C = gsl_matrix_calloc (N, N); // temporary storage
895 gsl_vector *s = gsl_vector_alloc (N); // eigenvalues AA^T
896 gsl_matrix *II= gsl_matrix_calloc (N,N); // testing idenity
897
898 //printf("INPUT \n");
899 //for(i=0;i<(N*N);i++)
900 //{
901 //printf("%e", gsl_matrix_get(A, i/N, i%N));
902 //if(i%N==(N-1)) printf("\n");
903 //else printf("\t");
904 //}
905 //printf("\n");
906
907 /*********************************************************************
908 *
909 * COMPUTING INVERSE
910 * - PERFORM SVD
911 * - CALCULATE INVERSE
912 *
913 ********************************************************************/
914
915 // Prepare U for SVD
916 gsl_matrix_memcpy(U, A);
917
918 // Perform SVD
919 gsl_linalg_SV_decomp_jacobi(U, V, s);
920
921 // Compute Inverse S
922 for (i = 0; i<N; i++)
923 {
924 gsl_vector_set( s, i, 1./gsl_vector_get( s, i) );
925 gsl_matrix_set( InvS, i, i, gsl_vector_get( s, i) );
926 }
927
928 //printf("EIGENVECTORS \n");
929 //for(i=0;i<N;i++)
930 //{
931 //printf("%e", gsl_vector_get(s,i));
932 //if(i==(N-1)) printf("\n");
933 //else printf("\t");
934 //}
935 //printf("\n");
936
937 // Tranpose U
938 gsl_matrix_transpose(U);
939
940 // Multiply V and InvS
941 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
942 1.0, V, InvS,
943 0.0, C);
944
945 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
946 1.0, C, U,
947 0.0, InvA);
948
949 //printf("INVERSE \n");
950 //for(i=0;i<(N*N);i++)
951 //{
952 //printf("%e", gsl_matrix_get(InvA, i/N, i%N));
953 //if(i%N==(N-1)) printf("\n");
954 //else printf("\t");
955 //}
956 //printf("\n");
957
958 /*********************************************************************
959 *
960 * TESTING ACCURACY
961 * - A * INVA = 1
962 *
963 ********************************************************************/
964
965 gsl_blas_dgemm (CblasNoTrans, CblasNoTrans,
966 1.0, A, InvA,
967 0.0, II);
968
969 //printf("UNIT\n");
970 //for(i=0;i<(N*N);i++)
971 //{
972 //printf("%e", gsl_matrix_get(I, i/N, i%N));
973 //if(i%N==(N-1)) printf("\n");
974 //else printf("\t");
975 //}
976 //printf("\n");
977
978 /*********************************************************************
979 *
980 * CLEANING UP
981 *
982 ********************************************************************/
983
984 /* MATRICES */
985 //gsl_matrix_free(A);
986 gsl_matrix_free(U);
987 gsl_matrix_free(InvS);
988 //gsl_matrix_free(InvA);
989 gsl_matrix_free(V);
990 gsl_matrix_free(C);
991 gsl_matrix_free(II);
992 gsl_vector_free(s);
993
994 /*********************************************************************
995 *
996 * Detach Error handling
997 *
998 ********************************************************************/
999
1000 return;
1001}
1002
1004{
1005 /* Takes a set of N coefficients c_i and return
1006 * c[0]+ c[1]*logf ..+c[N-1]*logf^(N-1).
1007 * To simulate constant CE, call with only c[0] non zero */
1008
1009 REAL8 output = 0.0;
1010 int i;
1011 /* Space frequencies uniformly in logF */
1012 REAL8 logFreqs[Npoints];
1013 REAL8 deltalogf=(log10(freq_max)-log10(freq_min))/(REAL8)(Npoints-1);
1014 for (i=0; i<Npoints; i++) {
1015 logFreqs[i]=log10(freq_min)+deltalogf*i;
1016 }
1017 if (Npoints%2==0) fprintf(stderr,"The number of points used for the fit must be odd, in ConvertCoefficientsToFunction. Exiting\n");
1018
1019 REAL8 cen = logFreqs[(Npoints-1)/2];
1020 REAL8 logF = log10(f)-cen; // FIT USED CEN AS CENTRAL POINT!
1021
1022 for(i=0;i<FitOrder;i++)
1023 {
1024 output += coeff[i]*pow(logF, (REAL8) i);
1025 }
1026
1027 return output;
1028}
1029
1031{
1032 /* Takes an array of 3 numbers and return a calibraation error realization which is:
1033 *
1034 * flat (coeff[0]) + fluctuation (given by ~10% of the S6 1-sigma) for freq< coeff[1]
1035 * increasing with constant slope coeff[2] for freq>coeff[1]
1036 * */
1037 REAL8 output=coeff[Npoints];
1038 REAL8 heavi=coeff[Npoints+1];
1039 REAL8 slope=coeff[Npoints+2];
1040 if (f<heavi)
1041 output+=(ConvertCoefficientsToFunction(coeff,f)/10.);
1042 if (f>= heavi)
1043 output = slope*(f-heavi)+(output+(ConvertCoefficientsToFunction(coeff,heavi)/10.));
1044 return output;
1045}
void LALInferenceApplyCalibrationErrors(LALInferenceIFOData *IFOdata, ProcessParamsTable *commandLine)
static void FitErrorRealisation(INT4 R, INT4 N, REAL8 *y, REAL8 dlogf, REAL8 *D)
static void ApplyPhaseCalibrationErrors(COMPLEX16FrequencySeries *doff, REAL8 *Pcoeffs)
static INT4 getNamedDataOptionsByDetectors(ProcessParamsTable *commandLine, char ***ifos, char ***out, const char *name, UINT4 *N)
Parse the calibration command line looking for options of the kind —IFO-option value Unlike the corre...
static void fill_IFO_Pha_vars_from_IFOname(REAL8 *stddev, REAL8 *fbin, char *ifoname)
static void fill_IFO_Amp_vars_from_IFOname(REAL8 *stddev, REAL8 *fbin, char *ifoname)
static void ApplyBothPhaseAmplitudeErrors(COMPLEX16FrequencySeries *doff, REAL8 *Acoeffs, REAL8 *Pcoeffs)
static void CreateRandomPhaseCalibrationErrors(REAL8 *phacoeffs, int calib_seed_pha, char *ifoname)
static void ApplySquaredAmplitudeErrors(REAL8FrequencySeries *Spectrum, REAL8 *Acoeffs)
static void InvertMatrixSVD(gsl_matrix *A, gsl_matrix *InvA, int N)
static void ApplyAmplitudeCalibrationErrors(COMPLEX16FrequencySeries *doff, REAL8 *Acoeffs)
static void PrintCEtoFile(REAL8 *Acoeffs, REAL8 *Pcoeffs, LALInferenceIFOData *IFOdata, ProcessParamsTable *commandLine)
static void CreateRandomAmplitudeCalibrationErrors(REAL8 *ampcoeffs, int calib_seed_ampli, char *ifoname)
const REAL8 random_linearCE_bit
static REAL8 ConvertCoefficientsToFunction(REAL8 *coeff, REAL8 f)
static REAL8 ConvertRandTransitionSlopeToFunction(REAL8 *coeff, REAL8 f)
int j
int k
#define fprintf
const char *const name
int s
double e
#define LAL_PI
#define crect(re, im)
double complex COMPLEX16
double REAL8
uint32_t UINT4
int32_t INT4
float REAL4
ProcessParamsTable * LALInferenceGetProcParamVal(ProcessParamsTable *procparams, const char *name)
Returns the element of the process params table with "name".
void * XLALCalloc(size_t m, size_t n)
void * XLALRealloc(void *p, size_t n)
void XLALFree(void *p)
char char * XLALStringDuplicate(const char *s)
static const INT4 m
RandomParams * XLALCreateRandomParams(INT4 seed)
void XLALDestroyRandomParams(RandomParams *params)
void LALUniformDeviate(LALStatus *status, REAL4 *deviate, RandomParams *params)
static const INT4 a
M
list y
help
type
c
COMPLEX16Sequence * data
COMPLEX16 * data
Structure to contain IFO data.
Definition: LALInference.h:625
REAL8FrequencySeries * oneSidedNoisePowerSpectrum
Definition: LALInference.h:643
char name[DETNAMELEN]
Definition: LALInference.h:626
COMPLEX16FrequencySeries * freqData
What is this?
Definition: LALInference.h:639
COMPLEX16FrequencySeries * whiteFreqData
Buffer for frequency domain data.
Definition: LALInference.h:640
struct tagLALInferenceIFOData * next
ROQ data.
Definition: LALInference.h:659
REAL8 fLow
FFT plan needed for time/time-and-phase marginalisation.
Definition: LALInference.h:650
CHAR value[LIGOMETA_VALUE_MAX]
REAL8Sequence * data
REAL8 * data
double V
double df
char * outfile