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
LALInferenceMultibanding.c
Go to the documentation of this file.
1//
2// LALInferenceFVectorMultiBanding.c:
3//
4//
5// Created by Serena Vinciguerra on 17/02/2015.
6//
7//
8
9#include <stdio.h>
10#include <lal/Date.h>
11#include <lal/GenerateInspiral.h>
12#include <lal/LALInference.h>
13#include <lal/FrequencySeries.h>
14#include <lal/Units.h>
15#include <lal/StringInput.h>
16#include <lal/TimeSeries.h>
17#include <lal/LALDatatypes.h>
18#include <lal/Sequence.h>
19#include <lal/LALInferenceMultibanding.h>
20
21
22/** F(t) and T(f) for newtonian waveform */
23static double LALInferenceTimeFrequencyRelation(double mc, double inPar, UINT4 flag_f);
24
25
26static double LALInferenceTimeFrequencyRelation(double mc, double inPar, UINT4 flag_f)
27{
28 double outPar = 0.0;
29 if (!flag_f){
30 //outPar is time
31 inPar=inPar/1.1; /* dividing the frequency by a safety factor 1.1*/
32 outPar=-5.0*pow((8.0*LAL_PI*inPar),-8./3.)*pow(mc, -5./3.);
33 }
34 else{
35 //outPar is frequency
36 outPar=pow(-inPar/5.,-3./8.)*pow(mc,-5./8.)/(8.*LAL_PI);
37 }
38 return (outPar);
39}
40
41REAL8Sequence *LALInferenceMultibandFrequencies(int NBands, double f_min, double f_max, double deltaF0, double mc)
42{
43
44 if (0) printf("f_max %f", f_max);
45 if (NBands==0){
46 XLALPrintError("ERROR: ask for Multi Banding procedure with 0 bands!\n");
47 return NULL;
48 }
49
50 double mc_sec=mc*LAL_MTSUN_SI;
51
52 f_min=deltaF0*ceil(f_min/deltaF0);
53 f_max=deltaF0*floor(f_max/deltaF0);
54
55
56 double fi = f_min;
57 int n_max = floor(- log2(deltaF0*2.1));
58 float t_nmax= 1./(pow(2.,n_max)*deltaF0) - 2.1;
59 float f_nmax= LALInferenceTimeFrequencyRelation(mc_sec,-t_nmax,1);
60
61 int n_min = floor(- log2(deltaF0*(2.1 - LALInferenceTimeFrequencyRelation(mc_sec,f_min,0))));
62 if (n_min < 0 ) n_min = 0;
63 int max_NBands = 0;
64 max_NBands = n_max+1 - n_min;
65 if (NBands==-1)
66 NBands = max_NBands;
67 if (NBands > max_NBands){
68 XLALPrintError(" WORNING required number of bands bigger than the maximum allowed, new number of bands %i \n",max_NBands);
69 printf("WORNING required number of bands bigger than the maximum allowed, new number of bands %i \n",max_NBands);
70 NBands = max_NBands;
71 }
72
73 REAL8Vector *F_inf = XLALCreateREAL8Vector(NBands);
74 REAL8Vector *F_sup = XLALCreateREAL8Vector(NBands);
76 REAL8Vector *desired_df = XLALCreateREAL8Vector(NBands);
77 REAL8Sequence *Frequencies=NULL;
78
79 if (F_sup== NULL || F_inf==NULL || deltaF ==NULL) {
80 XLALPrintError(" ERROR F_inf/sup/deltaF MBfile == NULL.\n");
81 printf(" ERROR new/sup/deltaF (MB file)== NULL.\n");
82 exit(1);
83 }
84
85 F_inf->data[0]=f_min;
86 F_sup->data[NBands-1]=f_max;
87
88 int nC = 1;
89 if (NBands == 1) n_max = n_min;
90 deltaF->data[NBands - 1] = (pow(2.,n_max)*deltaF0);
91 F_inf->data[NBands - 1] = f_nmax;
92 F_sup->data[NBands - 1] = f_max;
93 fi = f_max;
94 int n_i = n_max;
95
96 for (int i=NBands - 1; i>=0; i--) {
97
98 if (i< NBands - 1){
99 n_i = n_i - 1;
100 if (n_i<0) n_i = 0 ;
101 deltaF->data[i] = (pow(2.,n_i)*deltaF0);
102 if (i< NBands - 1) F_sup->data[i] = F_inf->data[i+1];
103 double t_ni= 1./(pow(2.,n_i)*deltaF0) - 2.1;
104 F_inf->data[i] = LALInferenceTimeFrequencyRelation(mc_sec,-t_ni,1);
105 if(i == 0 && F_inf->data[i]<= f_min ) F_inf->data[i]= f_min;
106 if (i== 0 && F_inf->data[i] > f_min ) {
107 n_i = n_min;
108 deltaF->data[i] = (pow(2.,n_i)*deltaF0);
109 F_inf->data[i] = f_min;
110 }
111 }
112 while((fi-deltaF->data[i])>=F_inf->data[i]){
113 fi=fi-deltaF->data[i];
114 nC++;
115 }
116 }
117
118 UINT4 NFreq = nC;
119 Frequencies = XLALCreateREAL8Sequence(NFreq);
120 Frequencies->data[nC - 1]= f_max;
121 int k= nC - 1;
122 printf("PHASE INTERPOLATION ACTIVATED: %i bands used to define the %u frequencies at which compute the waveforms \n",NBands,NFreq);
123
124
125 for (int i=NBands - 1; i>=0; i--) {
126 while((Frequencies->data[k]-deltaF->data[i])>=F_inf->data[i]){
127 k--;
128 Frequencies->data[k] = Frequencies->data[k+1]-deltaF->data[i];
129 }
130 }
131
135 XLALDestroyREAL8Vector(desired_df);
136 return(Frequencies);
137
138}
static double LALInferenceTimeFrequencyRelation(double mc, double inPar, UINT4 flag_f)
F(t) and T(f) for newtonian waveform.
REAL8Sequence * LALInferenceMultibandFrequencies(int NBands, double f_min, double f_max, double deltaF0, double mc)
Create a list of frequencies to use in multiband template generation, between f_min and f_max mc is m...
int k
#define LAL_PI
#define LAL_MTSUN_SI
uint32_t UINT4
REAL8Sequence * XLALCreateREAL8Sequence(size_t length)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
REAL8 * data
double f_min
double f_max