LALInspiralWaveLength.c

Go to the documentation of this file.
00001 /*
00002 *  Copyright (C) 2007 David Churches, Duncan Brown, Jolien Creighton, B.S. Sathyaprakash, Thomas Cokelaer
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="LALInspiralWaveLengthCV">
00021 Author: Sathyaprakash, B. S.
00022 $Id: LALInspiralWaveLength.c,v 1.16 2007/06/08 14:41:49 bema Exp $
00023 </lalVerbatim>  */
00024 
00025 /*  <lalLaTeX>
00026 
00027 \subsection{Module \texttt{LALInspiralWaveLength.c}}
00028 
00029 Module to calculate the number of data points (to the nearest power of 2)
00030 needed to store a waveform.
00031 
00032 \subsubsection*{Prototypes}
00033 \vspace{0.1in}
00034 \input{LALInspiralWaveLengthCP}
00035 \idx{LALInspiralWaveLength()}
00036 \begin{itemize}
00037 \item {\tt length:} output, number of bins to the nearest power of 2
00038 greater than the minimum length required to store a wave of parameters as in {\tt params}.
00039 \item {\tt params:} input, parameters of the binary system. 
00040 \end{itemize}
00041 
00042 \subsubsection*{Description}
00043 
00044 
00045 This module first calls {\tt LALInspiralChooseModel,} which gives the length of the 
00046 waveform in seconds. That function returns an estimated waveform length. However, the 
00047 length might not be appropriate in some extreme cases (large masses and large lower 
00048 cut-off frequency). It is especially true in the EOB case. Therefore, we introduce 
00049 two constants namely LALINSPIRAL\_LENGTHOVERESTIMATION (in percentage) which 
00050 overestimate the length of the waveform and LALINSPIRAL\_MINIMALWAVELENGTH which is
00051 the minimal waveform length in seconds. Multiplying this by the sampling rate 
00052 {\tt params.tSampling} gives the minimum number of samples needed to hold the waveform. 
00053 To this are added the number of bins of leading and trailing zeroes requested by the user in 
00054 {\tt params.nStartPad} and {\tt params.nEndPad.} The resulting number is rounded to
00055 an upward power of 2 and returned in {\tt length}. 
00056 
00057 \subsubsection*{Algorithm}
00058 
00059 
00060 \subsubsection*{Uses}
00061 This function calls:\\
00062 \texttt{
00063 LALInspiralSetup\\
00064 LALInspiralChooseModel
00065 }
00066 
00067 \vfill{\footnotesize\input{LALInspiralWaveLengthCV}}
00068 
00069 </lalLaTeX>  */
00070 
00071 #include <lal/LALInspiral.h>
00072 #include <lal/LALStdlib.h>
00073 
00074 #define  LALINSPIRAL_LENGTHOVERESTIMATION  0.1       /* 10 % */
00075 #define  LALINSPIRAL_MINIMALWAVELENGTH     0.03125   /* 64 bins with a 2048Hz sampling*/
00076 
00077 
00078 NRCSID (LALINSPIRALWAVELENGTHC, "$Id: LALInspiralWaveLength.c,v 1.16 2007/06/08 14:41:49 bema Exp $");
00079 
00080 /*  <lalVerbatim file="LALInspiralWaveLengthCP"> */
00081 void 
00082 LALInspiralWaveLength(
00083    LALStatus        *status, 
00084    UINT4            *length,
00085    InspiralTemplate  params
00086    ) 
00087 { /* </lalVerbatim>  */
00088 
00089    INT4 ndx;
00090    REAL8 x;
00091    CHAR message[256];
00092    expnCoeffs ak;
00093    expnFunc func;
00094 
00095    INITSTATUS (status, "LALInspiralWaveLength", LALINSPIRALWAVELENGTHC);
00096    ATTATCHSTATUSPTR(status);
00097 
00098    ASSERT (params.nStartPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00099    ASSERT (params.nEndPad >= 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00100    ASSERT (params.tSampling > 0, status, LALINSPIRALH_ESIZE, LALINSPIRALH_MSGESIZE);
00101    ASSERT (&params, status, LALINSPIRALH_ENULL, LALINSPIRALH_MSGENULL);
00102 
00103    LALInspiralSetup (status->statusPtr, &ak, &params);
00104    CHECKSTATUSPTR(status);
00105    
00106    LALInspiralChooseModel(status->statusPtr, &func, &ak, &params);
00107    /* not checkstatus before but we check if everything is fine, 
00108       then we return the length otherwise length is zero*/
00109    if (status->statusPtr->statusCode == 0){
00110            /*we add a minimal value and 10 % of overestimation */
00111            x    = (1.+ LALINSPIRAL_LENGTHOVERESTIMATION) * (ak.tn + LALINSPIRAL_MINIMALWAVELENGTH ) * params.tSampling 
00112              + params.nStartPad + params.nEndPad;
00113            ndx  = ceil(log10(x)/log10(2.));
00114            *length = pow(2, ndx);
00115      
00116         DETATCHSTATUSPTR(status);
00117         RETURN(status);
00118    }
00119    else { 
00120         sprintf(message,
00121                 "size is zero for the following waveform: totalMass = %f, fLower = %f, approximant = %d @ %fPN"
00122                , params.mass1 + params.mass2, params.fLower, params.approximant, params.order/2.);
00123         LALWarning(status, message);
00124         *length = 0;
00125        
00126        DETATCHSTATUSPTR(status);
00127        RETURN(status);
00128      }
00129 }

Generated on Mon Sep 8 03:07:00 2008 for LAL by  doxygen 1.5.2