bpmprocess/ddc_gaussfilter.c

Go to the documentation of this file.
00001 
00006 #include <bpm/bpm_messages.h>
00007 #include <bpm/bpm_process.h>
00008 
00009 
00023 int ddc_gaussfilter( double **ddc, int ns, double fs, double filtBW, double epsFilt,
00024                      double **out ) {
00025 
00026   double omega, dt, tS, tstart, tstop, filt[2];
00027   int istart, istop, iS;
00028 
00029   if ( ! ddc || ! out ) {
00030     bpm_error( "Invalid pointer arguments for ddc_gaussfilter(...)",
00031                __FILE__, __LINE__ );
00032     return BPM_FAILURE;
00033   }
00034 
00035   // get frequency in rad/s
00036   omega = 2.*PI*filtBW;
00037 
00038   // determine cut-off time from cut-off parameter epsFilt
00039   dt = sqrt( 2.*log( omega / ( sqrt(2.*PI) * epsFilt ) ) ) / omega;
00040 
00041   for ( iS = 0; iS<ns; iS++ ) {
00042     // get time of sample we're currently doing
00043     sample_to_time( fs, ns, iS, &tS ); 
00044 
00045     // filter start and stop times
00046     tstart  = tS - dt;
00047     tstop   = tS + dt;
00048     
00049     // convert them to the sample number
00050     time_to_sample( fs, ns, tstart, &istart );
00051     time_to_sample( fs, ns, tstop, &istop );
00052     
00053     filt[Re] = 0.;
00054     filt[Im] = 0.;
00055 
00056     // perform the step
00057     if ( ddc_gaussfilter_step( ddc, ns, fs, istart, istop, tS, filtBW, filt ) == BPM_FAILURE ) {
00058       bpm_error( "Error executing step in ddc_gaussfilter(...)", __FILE__, __LINE__ );
00059       return BPM_FAILURE;
00060     }
00061 
00062     // filling output array
00063     out[iS][Re] = filt[Re];
00064     out[iS][Im] = filt[Im];
00065 
00066   } /* for ( iS = 0; iS<ns; iS++ ) */
00067 
00068   return BPM_SUCCESS;
00069 }

Generated on Thu Jan 10 10:18:04 2008 for libbpm by  doxygen 1.5.1