Commit 2d5b60e0 authored by Tyson Littenberg's avatar Tyson Littenberg

Merge branch 'glitch-subtraction-fix' into 'master'

tweaks to glitch subtraction steps for O3a catalog

See merge request lscsoft/bayeswave!167
parents 208b8da3 c608c1c6
Pipeline #120949 failed with stages
in 2 minutes and 34 seconds
...@@ -96,11 +96,12 @@ void kickstart_glitch_model(struct Data *data, struct Prior *prior, struct Model ...@@ -96,11 +96,12 @@ void kickstart_glitch_model(struct Data *data, struct Prior *prior, struct Model
FILE *waveletStartFile; FILE *waveletStartFile;
double *params = malloc(data->NW*(sizeof(double))); double *params = malloc(data->NW*(sizeof(double)));
int size; int size;
int d=0; int d;
int d_counter; int d_counter;
for(ifo=0; ifo<data->NI; ifo++) for(ifo=0; ifo<data->NI; ifo++)
{ {
d = 0;
sprintf(filename,"glitch_%s.dat",data->ifos[ifo]); sprintf(filename,"glitch_%s.dat",data->ifos[ifo]);
if( (waveletStartFile = fopen(filename,"r")) == NULL ) if( (waveletStartFile = fopen(filename,"r")) == NULL )
{ {
...@@ -147,7 +148,16 @@ void kickstart_glitch_model(struct Data *data, struct Prior *prior, struct Model ...@@ -147,7 +148,16 @@ void kickstart_glitch_model(struct Data *data, struct Prior *prior, struct Model
fclose(waveletStartFile); fclose(waveletStartFile);
//fill residual //fill residual
FILE *tempfile = fopen("tempfile.dat","w");
for(i=0; i<data->N; i++) data->r[ifo][i] = data->s[ifo][i] - model->glitch[ifo]->templates[i]; for(i=0; i<data->N; i++) data->r[ifo][i] = data->s[ifo][i] - model->glitch[ifo]->templates[i];
for(i=0; i<data->N/2; i++)
{
data->r[ifo][i] = data->s[ifo][i] - model->glitch[ifo]->templates[i];
fprintf(tempfile,"%lg %lg %lg\n",data->r[ifo][2*i]*data->r[ifo][2*i]+data->r[ifo][2*i+1]*data->r[ifo][2*i+1] ,
data->s[ifo][2*i]*data->s[ifo][2*i]+data->s[ifo][2*i+1]*data->s[ifo][2*i+1] ,
model->glitch[ifo]->templates[2*i]*model->glitch[ifo]->templates[2*i]+model->glitch[ifo]->templates[2*i+1]*model->glitch[ifo]->templates[2*i+1]);
}
fclose(tempfile);
} }
} }
free(params); free(params);
......
...@@ -97,14 +97,14 @@ void SineGaussianTime(double *hs, double *sigpar, int N, int flag, double Tobs) ...@@ -97,14 +97,14 @@ void SineGaussianTime(double *hs, double *sigpar, int N, int flag, double Tobs)
double t = imin*dt; double t = imin*dt;
//brute force //brute force
/*
t = 0.0; t = 0.0;
for(n=0; n<N; n++) for(n=0; n<N; n++)
{ {
arg = (t-t0)/tau; arg = (t-t0)/tau;
hs[n] += Amp * exp(-arg*arg) * cos(LAL_TWOPI*f0*(t-t0) + phi); hs[n] += Amp * exp(-arg*arg) * cos(LAL_TWOPI*f0*(t-t0) + phi);
t += dt; t += dt;
}*/ }
//recursive phase //recursive phase
double phase = LAL_TWOPI*f0*(t-t0) + phi; double phase = LAL_TWOPI*f0*(t-t0) + phi;
...@@ -120,7 +120,7 @@ void SineGaussianTime(double *hs, double *sigpar, int N, int flag, double Tobs) ...@@ -120,7 +120,7 @@ void SineGaussianTime(double *hs, double *sigpar, int N, int flag, double Tobs)
double dexpdt = exp( -(2.*dt2) / tau2 ); double dexpdt = exp( -(2.*dt2) / tau2 );
double env = exp( -((t0-t)*(t0-t)) / tau2 ); double env = exp( -((t0-t)*(t0-t)) / tau2 );
double dexp2it = exp( -((double)(imin)*2.*dt2) / tau2 ); double dexp2it = exp( -((double)(imin)*2.*dt2) / tau2 );
/*
for(n=imin; n<imax; n++) for(n=imin; n<imax; n++)
{ {
//wavelet //wavelet
...@@ -132,7 +132,7 @@ void SineGaussianTime(double *hs, double *sigpar, int N, int flag, double Tobs) ...@@ -132,7 +132,7 @@ void SineGaussianTime(double *hs, double *sigpar, int N, int flag, double Tobs)
//iterate wavelet amplitude //iterate wavelet amplitude
env *= dexpt*dexp2it; env *= dexpt*dexp2it;
dexp2it *= dexpdt; dexp2it *= dexpdt;
} }*/
} }
double SineGaussianDistance(double *params0, double *params1) double SineGaussianDistance(double *params0, double *params1)
......
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