Commit 94087295 authored by Salvatore Vitale's avatar Salvatore Vitale Committed by Tyson Littenberg

User to pass with command line the maximum number of lines

parent f6aa6cf2
......@@ -472,7 +472,7 @@ void CubicSplineGSL(int N, double *x, double *y, int Nint, double *xint, double
}
void create_dataParams(dataParams *data, double *f, int n)
void create_dataParams(dataParams *data, double *f, int n,int max_lines)
{
// length of segment in seconds, this should be read in from the frame file
......@@ -498,7 +498,7 @@ void create_dataParams(dataParams *data, double *f, int n)
data->fstep = 1./data->Tobs;//data->fmin;//16;//((data->fmax-data->fmin)/128);//256./data->Tobs;//30;//FSTEP;//9.0;//30.0;
// This sets the maximum number of Lorentzian lines.
data->tmax = 1000;
data->tmax = max_lines;
// approximate number of segments
data->sgmts = (int)((f[n-1]-f[0])/data->fstep)+2;
......@@ -1421,6 +1421,7 @@ void BayesLineSetup(struct BayesLineParams *bptr, double *freqData, double fmin,
int imin, imax;
int j;
double reFreq,imFreq;
int max_lines=bptr->maxBLLines;
bptr->data = malloc(sizeof(dataParams));
......@@ -1458,7 +1459,7 @@ void BayesLineSetup(struct BayesLineParams *bptr, double *freqData, double fmin,
}
// storage for data meta parameters
create_dataParams(bptr->data,bptr->freq,n);
create_dataParams(bptr->data,bptr->freq,n,max_lines);
// storage for master line model
create_lorentzianParams(bptr->lines_x,bptr->data->tmax);
......@@ -2400,7 +2401,7 @@ static void clean(double *D, double *Draw, double *sqf, double *freqs, double *S
}
void blstart(double *data, double *residual, int N, double dt, double fmin, int *Nsp, int *Nl, double *dspline, double *pspline, double *linef, double *lineh, double *lineQ, char *ifo)
void blstart(double *data, double *residual, int N, double dt, double fmin, int *Nsp, int *Nl, double *dspline, double *pspline, double *linef, double *lineh, double *lineQ, int max_lines, char *ifo)
{
int i, j, k, Nf, ii;
int Nlines;
......@@ -2449,7 +2450,7 @@ void blstart(double *data, double *residual, int N, double dt, double fmin, int
D = (double*)malloc(sizeof(double)* (N));
Draw = (double*)malloc(sizeof(double)* (N));
linew = (double*)malloc(sizeof(double)*(1000));
linew = (double*)malloc(sizeof(double)*(max_lines));
// Copy data over
for(i=0; i< N; i++)
......@@ -2795,15 +2796,14 @@ void BayesLineBurnin(struct BayesLineParams *bayesline, double *timeData, double
splineParams *spline = bayesline->spline_x;
int i,j;
int max_lines=bayesline->maxBLLines;
//number of samples in the data
double Tobs = data->Tobs;
double fmax = data->fmax;
double dt = 1./data->cadence;
int N = 2*(int)floor(fmax*Tobs);
blstart(timeData, freqData, N, dt, data->fmin, &spline->n, &lines->n, spline->data, spline->points, lines->f, lines->A, lines->Q, ifo);
blstart(timeData, freqData, N, dt, data->fmin, &spline->n, &lines->n, spline->data, spline->points, lines->f, lines->A, lines->Q, max_lines, ifo);
//Work space for assembling PSD model
double *f = malloc(sizeof(double)*(N+1));
......
......@@ -110,7 +110,7 @@ struct BayesLineParams
double *sfreq;
double *Sbase;
double *Sline;
int maxBLLines;
int constantLogLFlag;
int flatPriorFlag;
......@@ -142,7 +142,7 @@ void spectrum_spline(double *Sn, double *Sbase, double *sfreq, dataParams *data,
void CubicSplineGSL(int N, double *x, double *y, int Nint, double *xint, double *yint);
void create_dataParams(dataParams *data, double *f, int n);
void create_dataParams(dataParams *data, double *f, int n,int max_lines);
void create_lorentzianParams(lorentzianParams *lines, int size);
void copy_lorentzianParams(lorentzianParams *origin, lorentzianParams *copy);
......
......@@ -51,6 +51,7 @@ int main(int argc, char *argv[])
/* Variable declaration */
int i, j, ic, ifo, imin,imax;
int maxBLLines=1000;
char filename[MAXSTRINGSIZE];
char modelname[MAXSTRINGSIZE];
......@@ -360,6 +361,10 @@ int main(int argc, char *argv[])
if(data->bayesLineFlag)
{
fprintf(stdout,"\n ============ BayesLine ==============\n");
/*Allow use to increase max number f lines for bayesline burnin*/
if(LALInferenceGetProcParamVal(runState->commandLine,"--max-BL-lines"))
maxBLLines=atoi((LALInferenceGetProcParamVal(runState->commandLine,"--max-BL-lines"))->value);
fprintf(stdout,"Setting maximum number of BL lines to %d for IFO %s\n", maxBLLines);
/*
Setup BayesLine structure
......@@ -367,7 +372,7 @@ int main(int argc, char *argv[])
for(ic=0; ic<chain->NC; ic++)
{
bayesline[ic] = malloc(data->NI*sizeof(struct BayesLineParams *));
initialize_bayesline(bayesline[ic], data, psd);
initialize_bayesline(bayesline[ic], data, psd,maxBLLines);
}
/*
......@@ -413,7 +418,7 @@ int main(int argc, char *argv[])
//normalize time series as expected by BayesLine
for(i=0; i<N; i++) timeData[ifo][i]/=data->Tobs;
bayesline[0][ifo]->maxBLLines=maxBLLines;
fprintf(stdout,"BayesLine search phase for IFO %s\n", data->ifos[ifo]);
BayesLineBurnin(bayesline[0][ifo], timeData[ifo], asd, data->ifos[ifo]);
......
......@@ -334,15 +334,15 @@ void allocate_chain(struct Chain *chain, int NI, int NP)
}
}
void resize_model(struct Data *data, struct Chain *chain, struct Prior *prior, struct Model **model, struct BayesLineParams ***bayesline, double **psd, int NC)
void resize_model(struct Data *data, struct Chain *chain, struct Prior *prior, struct Model **model, struct BayesLineParams ***bayesline, double **psd, int NC,int max_lines)
{
int ic,ifo;
printf("in resize model bayeslinee %d \n", bayesline[0][0]->maxBLLines);
fprintf(stdout, " Resizing model for number of chains from %i to %i\n",chain->NC,NC);
struct BayesLineParams **bptr;
bptr=malloc(data->NI*sizeof(struct BayesLineParams *));
initialize_bayesline(bptr,data,psd);
initialize_bayesline(bptr,data,psd,max_lines);
for(ifo=0; ifo<data->NI; ifo++) copy_bayesline_params(bayesline[0][ifo], bptr[ifo]);
......@@ -371,7 +371,7 @@ void resize_model(struct Data *data, struct Chain *chain, struct Prior *prior, s
initialize_model(model[ic], data, prior, psd, chain->seed);
bayesline[ic] = malloc(data->NI*sizeof(struct BayesLineParams *));
initialize_bayesline(bayesline[ic], data, psd);
initialize_bayesline(bayesline[ic], data, psd,max_lines);
for(ifo=0; ifo<data->NI; ifo++) copy_bayesline_params(bptr[ifo], bayesline[ic][ifo]);
}
......@@ -896,7 +896,7 @@ void free_bayesline(struct BayesLineParams **bayesline, struct Data *data)
}
void initialize_bayesline(struct BayesLineParams **bayesline, struct Data *data, double **psd)
void initialize_bayesline(struct BayesLineParams **bayesline, struct Data *data, double **psd,int max_lines)
{
int i,ifo;
......@@ -912,7 +912,7 @@ void initialize_bayesline(struct BayesLineParams **bayesline, struct Data *data,
bayesline[ifo]->priors->lower = malloc(N*sizeof(double));
bayesline[ifo]->priors->mean = malloc(N*sizeof(double));
bayesline[ifo]->priors->sigma = malloc(N*sizeof(double));
bayesline[ifo]->maxBLLines=max_lines;
//Set BayesLine priors based on the data channel being used
set_bayesline_priors(data->channels[ifo], bayesline[ifo], data->Tobs);
......
......@@ -49,7 +49,7 @@ void free_fisher(struct FisherMatrix *fisher);
void free_chain (struct Chain *chain, int NI, int NP);
void allocate_chain (struct Chain *chain, int NI, int NP);
void initialize_chain (struct Chain *chain, int flag);
void resize_model (struct Data *data, struct Chain *chain, struct Prior *prior, struct Model **model, struct BayesLineParams ***bayesline, double **psd, int NC);
void resize_model (struct Data *data, struct Chain *chain, struct Prior *prior, struct Model **model, struct BayesLineParams ***bayesline, double **psd, int NC, int max_lines);
void reset_priors (struct Data *data, struct Prior *prior);
void initialize_priors (struct Data *data, struct Prior *prior, int omax);
......@@ -64,7 +64,7 @@ void copy_ext_model (struct Model *origin, struct Model *copy, int N, int NI)
void copy_psd_model (struct Model *origin, struct Model *copy, int N, int NI);
void free_bayesline(struct BayesLineParams **bayesline, struct Data *data);
void initialize_bayesline(struct BayesLineParams **bayesline, struct Data *data, double **psd);
void initialize_bayesline(struct BayesLineParams **bayesline, struct Data *data, double **psd,int max_lines);
void reset_likelihood(struct Data *data);
void reset_params(struct Wavelet *wave_x, struct Wavelet *wave_y, double **range);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment