From 147ed3dcb8841f696cbae28be43c479bbf950019 Mon Sep 17 00:00:00 2001 From: Madeline Wade <madeline.wade@ligo.org> Date: Mon, 30 Oct 2017 17:56:10 -0700 Subject: [PATCH] Fixed the latency and default filter length in fcc filter updating --- gstlal-calibration/bin/gstlal_compute_strain | 6 ++-- gstlal-calibration/gst/lal/gstlal_fccupdate.c | 33 ++++++++++--------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/gstlal-calibration/bin/gstlal_compute_strain b/gstlal-calibration/bin/gstlal_compute_strain index 9b317504c7..4603972be2 100644 --- a/gstlal-calibration/bin/gstlal_compute_strain +++ b/gstlal-calibration/bin/gstlal_compute_strain @@ -208,7 +208,7 @@ parser.add_option("--pcal-channel-name", metavar = "name", default = "CAL-PCALY_ parser.add_option("--dewhitening", action = "store_true", help = "Dewhitening should be used on the relevant channels, since the incoming channels are whitened and single precision.") parser.add_option("--low-latency", action = "store_true", help = "Run the pipeline in low-latency mode. This uses minimal queueing. Otherwise, maximal queueing is used to prevent the pipeline from locking up.") parser.add_option("--update-fcc", action = "store_true", help = "Update the cavity pole filter with time.") -parser.add_option("--fcc-filter-duration", metavar = "seconds", default = 0.01, help = "Duration of the cavity pole FIR filter. (Default = 0.01 seconds)") +parser.add_option("--fcc-filter-duration", metavar = "seconds", default = 1.0, type = float, help = "Duration of the cavity pole FIR filter. (Default = 0.01 seconds)") parser.add_option("--fcc-averaging-time", metavar = "seconds", type = float, default = 60, help = "Length of time (in seconds) between when cavity pole FIR filter is updated. The computed cavity pole values are averaged between the update intervals in order to obtain the cavity pole value used to compute the new FIR filter. (Default = 60 seconds)") parser.add_option("--fcc-filter-taper-length", metavar = "samples", type = int, default = 16384, help = "Number of samples to be used when tapering old filter and ramping in new filter. (Default = 16384)") @@ -1130,8 +1130,8 @@ if options.dewhitening: res_filter_latency += float(resdewhitendelay)/hoftsr if options.update_fcc: - default_fir_matrix = numpy.zeros(int(hoftsr*options.fcc_filter_duration-1)) - latency = int(len(default_fir_matrix)/2) + default_fir_matrix = numpy.zeros(int(numpy.floor(hoftsr*options.fcc_filter_duration/2.0+1)*2.0-2.0)) + latency = int(hoftsr*options.fcc_filter_duration/(2.0)+1) default_fir_matrix[latency] = 1.0 res = pipeparts.mkgeneric(pipeline, res, "lal_tdwhiten", kernel = default_fir_matrix[::-1], latency = latency, taper_length = options.fcc_filter_taper_length) update_fcc.connect("notify::fir-matrix", fir_matrix_update, res) diff --git a/gstlal-calibration/gst/lal/gstlal_fccupdate.c b/gstlal-calibration/gst/lal/gstlal_fccupdate.c index 5ccd7f3d2a..bff44df6c2 100644 --- a/gstlal-calibration/gst/lal/gstlal_fccupdate.c +++ b/gstlal-calibration/gst/lal/gstlal_fccupdate.c @@ -176,24 +176,24 @@ float *tukey(int N) //constructs the new filter with the computed average -long double* MakeFilter(GSTLALFccUpdate *element) { - long double FcAverage=element->currentaverage; +double* MakeFilter(GSTLALFccUpdate *element) { + double FcAverage=element->currentaverage; - printf("FcAverage=%Lf \n",FcAverage); + printf("FcAverage=%lf \n",FcAverage); - long double FiltDur=(long double) element->filterduration; - long double Filtdf=1.0L/(long double)FiltDur; - long double Filtdt=1.0L/(long double) element->datarate; + double FiltDur=(double) element->filterduration; + double Filtdf=1.0L/(double)FiltDur; + double Filtdt=1.0L/(double) element->datarate; int filtlength= (int) (element->datarate/(2.0*Filtdf))+1; int i=0; - long double Filtf[filtlength]; + double Filtf[filtlength]; while(i<filtlength) { Filtf[i]=(i*Filtdf); i++; } i=0; - long double complex CavPoleFiltForTD[filtlength]; + double complex CavPoleFiltForTD[filtlength]; double instrument_cavity_pole_frequency = element->fcmodel; while(i<filtlength) { @@ -204,13 +204,13 @@ long double* MakeFilter(GSTLALFccUpdate *element) { //adds delay to the filter i=0; double delaysamples=filtlength; - long double complex Delay[filtlength]; + double complex Delay[filtlength]; while(i<filtlength) { - Delay[i]=cexpl(-2.0L*Pi*I*Filtf[i]*delaysamples*Filtdt); + Delay[i]=cexpl(-2.0*Pi*I*Filtf[i]*delaysamples*Filtdt); i++; } i=0; - long double complex DelayedFilt[filtlength]; + double complex DelayedFilt[filtlength]; while(i<filtlength) { DelayedFilt[i]=CavPoleFiltForTD[i]*Delay[i]; i++; @@ -218,13 +218,13 @@ long double* MakeFilter(GSTLALFccUpdate *element) { //adds the negative frequencies to the filter to prepare for ifft i=0; - long double complex NegFrequencies[filtlength]; + double complex NegFrequencies[filtlength]; while(i<filtlength) { NegFrequencies[i]=conjl(DelayedFilt[(filtlength-1-i)]); i++; } - long double complex CavPoleFiltTotal[filtlength*2-2]; + double complex CavPoleFiltTotal[filtlength*2-2]; i=0; while(i<filtlength) { CavPoleFiltTotal[i]=DelayedFilt[i]; @@ -253,7 +253,7 @@ long double* MakeFilter(GSTLALFccUpdate *element) { fftw_execute(p); i=0; - long double * CavPoleFiltTD=malloc(sizeof(long double)*N); + double * CavPoleFiltTD=malloc(sizeof(double)*N); while(i<N) { CavPoleFiltTD[i]=creall(out[i]/N); @@ -285,8 +285,9 @@ long double* MakeFilter(GSTLALFccUpdate *element) { //prints out CavPoleFiltTD //FILE *fptr; //fptr = fopen("cavitypolfilter.txt", "w"); + //printf("Filter length is %d\n", N); //for(i=0;i<N;i++) { - // fprintf(fptr, "%Lf \n",CavPoleFiltTD[i]); + // fprintf(fptr, "%lf \n",CavPoleFiltTD[i]); //} @@ -388,7 +389,7 @@ static GstFlowReturn transform_ip(GstBaseTransform *trans, GstBuffer *buf) { printf("reached update length\n"); //makes the new fir_matrix using the current average fcc_filter value int filtlength=((int)(element->datarate*element->filterduration/2.0))*2; - long double *FccFilter=MakeFilter(element); + double *FccFilter=MakeFilter(element); //updated the values of the fir_matrix element->fir_matrix=gsl_matrix_alloc(1,filtlength); -- GitLab