TimeFreqFFT.h

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 Duncan Brown, Jolien Creighton, Kipp Cannon, Patrick Brady, Tania Regimbau
00003 *
00004 *  This program is free software; you can redistribute it and/or modify
00005 *  it under the terms of the GNU General Public License as published by
00006 *  the Free Software Foundation; either version 2 of the License, or
00007 *  (at your option) any later version.
00008 *
00009 *  This program is distributed in the hope that it will be useful,
00010 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 *  GNU General Public License for more details.
00013 *
00014 *  You should have received a copy of the GNU General Public License
00015 *  along with with program; see the file COPYING. If not, write to the
00016 *  Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
00017 *  MA  02111-1307  USA
00018 */
00019 
00020 /**** <lalVerbatim file="TimeFreqFFTHV">
00021  * $Id: TimeFreqFFT.h,v 1.23 2008/09/30 00:45:41 kipp Exp $
00022  **** </lalVerbatim> */
00023 
00024 /**** <lalLaTeX>
00025  *
00026  * \section{Header \texttt{TimeFreqFFT.h}}
00027  * \label{s:TimeFreqFFT.h}
00028  * 
00029  * Performs real-to-complex, complex-to-real FFTs and average power
00030  * spectrum estimation.
00031  * 
00032  * \subsection*{Synopsis}
00033  * \begin{verbatim}
00034  * #include <lal/TimeFreqFFT.h>
00035  * \end{verbatim}
00036  * 
00037  * \noindent Perform time-to-frequency and frequency-to-time fast Fourier
00038  * transforms. Also provides a function to compute mean and median power
00039  * spectra with user specified windowning.
00040  * 
00041  **** </lalLaTeX> */
00042 
00043 /** \defgroup fft Fourier Transform and Spectral Methods
00044  *
00045  * Performs real-to-complex, complex-to-real FFTs and average power
00046  * spectrum estimation.
00047  * 
00048  * Perform time-to-frequency and frequency-to-time fast Fourier
00049  * transforms. Also provides a function to compute mean and median power
00050  * spectra with user specified windowning.
00051  *
00052  * The definition of the Fourier transform is \f$ e^{2 \pi i f t} \f$
00053  * and the inline equation version of that is
00054  * \f[
00055  *  \tilde{h}_k = \sum
00056  * \f]
00057  * 
00058  * 
00059  */
00060 
00061 #ifndef _TIMEFREQFFT_H
00062 #define _TIMEFREQFFT_H
00063 
00064 #include <lal/LALDatatypes.h>
00065 #include <lal/ComplexFFT.h>
00066 #include <lal/RealFFT.h>
00067 #include <lal/Window.h>
00068 
00069 #ifdef  __cplusplus
00070 extern "C" {
00071 #pragma }
00072 #endif
00073 
00074 NRCSID( TIMEFREQFFTH, "$Id: TimeFreqFFT.h,v 1.23 2008/09/30 00:45:41 kipp Exp $" );
00075 
00076 /**** <lalLaTeX>
00077  * \subsection*{Error conditions}
00078  **** </lalLaTeX> */
00079 /**** <lalErrTable> */
00080 
00081 #define TIMEFREQFFTH_ENULL 1
00082 #define TIMEFREQFFTH_ESIZE 2
00083 #define TIMEFREQFFTH_ERATE 4
00084 #define TIMEFREQFFTH_ESIGN 4
00085 #define TIMEFREQFFTH_EALLOC 16
00086 #define TIMEFREQFFTH_EPOSARG 32
00087 #define TIMEFREQFFTH_EMALLOC 64
00088 #define TIMEFREQFFTH_EINCOMP 128
00089 #define TIMEFREQFFTH_ENNUL 256
00090 #define TIMEFREQFFTH_EZSEG 512
00091 #define TIMEFREQFFTH_EZOVR 1024
00092 #define TIMEFREQFFTH_EMISM 2048
00093 #define TIMEFREQFFTH_EUAVG 4096
00094 
00095 #define TIMEFREQFFTH_MSGENULL "Null pointer"
00096 #define TIMEFREQFFTH_MSGESIZE "Invalid size"
00097 #define TIMEFREQFFTH_MSGERATE "Invalid rate"
00098 #define TIMEFREQFFTH_MSGESIGN "Incorrect plan sign"
00099 #define TIMEFREQFFTH_MSGEALLOC "Pointer has already been allocated, should be null"
00100 #define TIMEFREQFFTH_MSGEPOSARG "Argument must be positive"
00101 #define TIMEFREQFFTH_MSGEMALLOC "Malloc failure"
00102 #define TIMEFREQFFTH_MSGEINCOMP "Incompatible arguments"
00103 #define TIMEFREQFFTH_MSGENNUL "Non-null pointer"
00104 #define TIMEFREQFFTH_MSGEZSEG "Segment length is zero"
00105 #define TIMEFREQFFTH_MSGEZOVR "Overlap length is zero"
00106 #define TIMEFREQFFTH_MSGEMISM "Mismatch beteen segment, overlap and data length"
00107 #define TIMEFREQFFTH_MSGEUAVG "Unknown average power spectum method"
00108 
00109 /**** </lalErrTable> */
00110 
00111 /* <lalLaTeX>
00112 \subsection*{Types}
00113 
00114 \subsubsection*{Enum type \texttt{AvgSpecMethod}}
00115 \idx[Type]{AvgSpecMethod}
00116 
00117 This type determines the method the type of average that will be used to
00118 compute the power sperum estimate by the \verb|LALREAL4AverageSpectrum()|
00119 function. The function computes a series of (possibly overlapping) power
00120 spectra and computes the average using one of the following methods:
00121 
00122 \begin{description}
00123 \item[\texttt{useUnity}] A constant PSD of value unity will be returned
00124 independent of the input data given. This is used for testing purposes.
00125 
00126 \item[\texttt{useMean}] The arithmetic mean of the individual power spectra 
00127 computed will be used to compute the output power spectrum.
00128 
00129 \item[\texttt{useMedian}] The median value of the individual power spectra 
00130 computed will be used to compute the output power spectrum.
00131 
00132 \item[\texttt{NumberAvgSpecMethods}] gives the number of defined methods.
00133 \end{description}
00134 
00135 </lalLaTeX> */
00136 
00137 typedef enum
00138 {
00139   useUnity,
00140   useMean,
00141   useMedian,
00142   NumberAvgSpecMethods
00143 } 
00144 AvgSpecMethod;
00145 
00146 /* <lalLaTeX>
00147 \subsubsection*{Structure \texttt{AvgerageSpectrumParams}}
00148 \idx[Type]{AverageSpectrumParams}
00149 
00150 This structure controls the behaviour of the \verb|LALREAL4AverageSpectrum()|
00151 function.
00152 
00153 \begin{description}
00154 \item[\texttt{REAL4Window *window}] The windowing function to use when
00155 computing the individual power spectra from the input time series. The
00156 input time series is broken into smaller time series to compute power spectra
00157 for the estimate. The legth of these time series is determined by the
00158 \texttt{length} parameter of the window vector.
00159 
00160 \item[\texttt{UINT4 overlap}] The overlap between sucessive time series used
00161 to compute the power spectra.
00162 
00163 \item[\texttt{AvgSpecMethod method}] The method of computing the average
00164 as describe above.
00165 
00166 \item[\texttt{RealFFTPlan *plan}] The FFT plan to be used in the computation
00167 of the power spectrum.
00168 
00169 \end{description}
00170 
00171 </lalLaTeX> */
00172 
00173 typedef struct
00174 tagAverageSpectrumParams
00175 {
00176   REAL4Window          *window;
00177   UINT4                 overlap;
00178   AvgSpecMethod         method;
00179   RealFFTPlan          *plan;
00180 }
00181 AverageSpectrumParams;
00182 
00183 typedef struct
00184 tagLALPSDRegressor
00185 {
00186   int max_samples;
00187   int n_samples;
00188   COMPLEX16FrequencySeries *mean;
00189   REAL8FrequencySeries *mean_square;
00190 }
00191 LALPSDRegressor;
00192 
00193 /**** <lalLaTeX>
00194  * \newpage\input{TimeFreqFFTC}
00195  * \newpage\input{TimeFreqFFTTestC}
00196  **** </lalLaTeX> */
00197 
00198 /*
00199  *
00200  * XLAL Functions
00201  *
00202  */
00203 
00204 int XLALREAL4TimeFreqFFT(
00205     COMPLEX8FrequencySeries *freq, 
00206     const REAL4TimeSeries   *tser,
00207     const REAL4FFTPlan      *plan
00208     );
00209 
00210 int XLALREAL4FreqTimeFFT(
00211     REAL4TimeSeries               *tser,
00212     const COMPLEX8FrequencySeries *freq, 
00213     const REAL4FFTPlan            *plan
00214     );
00215 
00216 int XLALREAL8TimeFreqFFT(
00217     COMPLEX16FrequencySeries *freq, 
00218     const REAL8TimeSeries    *tser,
00219     const REAL8FFTPlan       *plan
00220     );
00221 
00222 int XLALREAL8FreqTimeFFT(
00223     REAL8TimeSeries                *tser,
00224     const COMPLEX16FrequencySeries *freq, 
00225     const REAL8FFTPlan             *plan
00226     );
00227 
00228 int XLALCOMPLEX8TimeFreqFFT(
00229     COMPLEX8FrequencySeries  *freq,
00230     const COMPLEX8TimeSeries *tser,
00231     const COMPLEX8FFTPlan    *plan
00232     );
00233 
00234 int XLALCOMPLEX8FreqTimeFFT(
00235     COMPLEX8TimeSeries            *tser,
00236     const COMPLEX8FrequencySeries *freq,
00237     const COMPLEX8FFTPlan         *plan
00238     );
00239 
00240 int XLALCOMPLEX16TimeFreqFFT(
00241     COMPLEX16FrequencySeries  *freq,
00242     const COMPLEX16TimeSeries *tser,
00243     const COMPLEX16FFTPlan    *plan
00244     );
00245 
00246 int XLALCOMPLEX16FreqTimeFFT(
00247     COMPLEX16TimeSeries            *tser,
00248     const COMPLEX16FrequencySeries *freq,
00249     const COMPLEX16FFTPlan         *plan
00250     );
00251 
00252 int XLALREAL4ModifiedPeriodogram(
00253     REAL4FrequencySeries        *periodogram,
00254     const REAL4TimeSeries       *tseries,
00255     const REAL4Window           *window,
00256     const REAL4FFTPlan          *plan
00257     );
00258 
00259 int XLALREAL8ModifiedPeriodogram(
00260     REAL8FrequencySeries        *periodogram,
00261     const REAL8TimeSeries       *tseries,
00262     const REAL8Window           *window,
00263     const REAL8FFTPlan          *plan
00264     );
00265 
00266 int XLALREAL4AverageSpectrumWelch(
00267     REAL4FrequencySeries        *spectrum,
00268     const REAL4TimeSeries       *tseries,
00269     UINT4                        seglen,
00270     UINT4                        stride,
00271     const REAL4Window           *window,
00272     const REAL4FFTPlan          *plan
00273     );
00274 
00275 int XLALREAL8AverageSpectrumWelch(
00276     REAL8FrequencySeries        *spectrum,
00277     const REAL8TimeSeries       *tseries,
00278     UINT4                        seglen,
00279     UINT4                        stride,
00280     const REAL8Window           *window,
00281     const REAL8FFTPlan          *plan
00282     );
00283 
00284 REAL8 XLALMedianBias( UINT4 nn );
00285 
00286 int XLALREAL4AverageSpectrumMedian(
00287     REAL4FrequencySeries        *spectrum,
00288     const REAL4TimeSeries       *tseries,
00289     UINT4                        seglen,
00290     UINT4                        stride,
00291     const REAL4Window           *window,
00292     const REAL4FFTPlan          *plan
00293     );
00294 
00295 int XLALREAL8AverageSpectrumMedian(
00296     REAL8FrequencySeries        *spectrum,
00297     const REAL8TimeSeries       *tseries,
00298     UINT4                        seglen,
00299     UINT4                        stride,
00300     const REAL8Window           *window,
00301     const REAL8FFTPlan          *plan
00302     );
00303 
00304 int XLALREAL4AverageSpectrumMedianMean(
00305     REAL4FrequencySeries        *spectrum,
00306     const REAL4TimeSeries       *tseries,
00307     UINT4                        seglen,
00308     UINT4                        stride,
00309     const REAL4Window           *window,
00310     const REAL4FFTPlan          *plan
00311     );
00312 
00313 int XLALREAL8AverageSpectrumMedianMean(
00314     REAL8FrequencySeries        *spectrum,
00315     const REAL8TimeSeries       *tseries,
00316     UINT4                        seglen,
00317     UINT4                        stride,
00318     const REAL8Window           *window,
00319     const REAL8FFTPlan          *plan
00320     );
00321 
00322 int XLALREAL4SpectrumInvertTruncate(
00323     REAL4FrequencySeries        *spectrum,
00324     REAL4                        lowfreq,
00325     UINT4                        seglen,
00326     UINT4                        trunclen,
00327     REAL4FFTPlan                *fwdplan,
00328     REAL4FFTPlan                *revplan
00329     );
00330 
00331 int XLALREAL8SpectrumInvertTruncate(
00332     REAL8FrequencySeries        *spectrum,
00333     REAL8                        lowfreq,
00334     UINT4                        seglen,
00335     UINT4                        trunclen,
00336     REAL8FFTPlan                *fwdplan,
00337     REAL8FFTPlan                *revplan
00338     );
00339 
00340 REAL4TimeSeries *XLALRespFilt(
00341     REAL4TimeSeries             *strain,
00342     COMPLEX8FrequencySeries     *transfer
00343     );
00344 
00345 REAL4TimeSeries *XLALREAL4Convolution(
00346     REAL4TimeSeries             *strain,
00347     REAL4TimeSeries             *transfer
00348     );
00349 
00350 COMPLEX8FrequencySeries *XLALWhitenCOMPLEX8FrequencySeries(
00351     COMPLEX8FrequencySeries     *fseries,
00352     const REAL4FrequencySeries  *psd
00353     );
00354 
00355 COMPLEX16FrequencySeries *XLALWhitenCOMPLEX16FrequencySeries(
00356     COMPLEX16FrequencySeries    *fseries,
00357     const REAL8FrequencySeries  *psd
00358 );
00359 
00360 void
00361 LALTimeFreqRealFFT(
00362     LALStatus               *status,
00363     COMPLEX8FrequencySeries *fser,
00364     REAL4TimeSeries         *tser,
00365     RealFFTPlan             *plan
00366     );
00367 
00368 void
00369 LALFreqTimeRealFFT(
00370     LALStatus               *status,
00371     REAL4TimeSeries         *tser,
00372     COMPLEX8FrequencySeries *fser,
00373     RealFFTPlan             *plan
00374     );
00375 
00376 void
00377 LALREAL4AverageSpectrum (
00378     LALStatus                   *status,
00379     REAL4FrequencySeries        *fSeries,
00380     REAL4TimeSeries             *tSeries,
00381     AverageSpectrumParams       *params
00382     );
00383 void
00384 LALCOMPLEX8AverageSpectrum (
00385     LALStatus                   *status,
00386     COMPLEX8FrequencySeries     *fSeries,
00387     REAL4TimeSeries             *tSeries0,
00388     REAL4TimeSeries             *tSeries1,
00389     AverageSpectrumParams       *params
00390     );
00391 void
00392 LALTimeFreqComplexFFT(
00393     LALStatus               *status,
00394     COMPLEX8FrequencySeries *fser,
00395     COMPLEX8TimeSeries      *tser,
00396     ComplexFFTPlan          *plan
00397     );
00398 
00399 void
00400 LALFreqTimeComplexFFT(
00401     LALStatus               *status,
00402     COMPLEX8TimeSeries      *tser,
00403     COMPLEX8FrequencySeries *fser,
00404     ComplexFFTPlan          *plan
00405     );
00406 
00407 LALPSDRegressor *
00408 XLALPSDRegressorNew(
00409     int max_samples
00410 );
00411 
00412 void
00413 XLALPSDRegressorFree(
00414     LALPSDRegressor *r
00415 );
00416 
00417 void
00418 XLALPSDRegressorReset(
00419     LALPSDRegressor *r
00420 );
00421 
00422 int
00423 XLALPSDRegressorAdd(
00424     LALPSDRegressor *r,
00425     const COMPLEX16FrequencySeries *sample
00426 );
00427 
00428 COMPLEX16FrequencySeries *
00429 XLALPSDRegressorGetMean(
00430     const LALPSDRegressor *r,
00431     const LIGOTimeGPS *epoch,
00432     REAL8 min_sigma_sq
00433 );
00434 
00435 REAL8FrequencySeries *
00436 XLALPSDRegressorGetPSD(
00437     const LALPSDRegressor *r
00438 );
00439 
00440 int
00441 XLALPSDRegressorSetPSD(
00442     LALPSDRegressor *r,
00443     const REAL8FrequencySeries *psd,
00444     int weight
00445 );
00446 
00447 #ifdef  __cplusplus
00448 #pragma {
00449 }
00450 #endif
00451 
00452 #endif /* _TIMEFREQFFT_H */

Generated on Mon Oct 13 02:32:21 2008 for LAL by  doxygen 1.5.2