00001 /* 00002 * Copyright (C) 2007 Jolien Creighton, Maria Alessandra Papa, Reinhard Prix, Steve Berukoff, Xavier Siemens 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="LALDemodHV"> 00021 Author: Berukoff, S.J., Papa, M.A. 00022 $Id: LALDemod.h,v 1.21 2007/06/08 14:41:50 bema Exp $ 00023 *** </lalVerbatim> */ 00024 00025 /* <lalLaTeX> 00026 \section{Header \texttt{LALDemod.h}} 00027 \label{s:LALDemod.h} 00028 Computes a demodulated transform. 00029 00030 \subsection*{Synopsis} 00031 \begin{verbatim} 00032 #include <lal/LALDemod.h> 00033 \end{verbatim} 00034 00035 \noindent The following is a brief synopsis of the demodulation, or 'Coherent Transform', procedure. 00036 00037 In order to remove frequency and amplitude modulation of a time series $x_a$, we need two basic components: 00038 \begin{description} 00039 \item[\bf{Frequency modulation information}] This is given through a phase model $\Phi$. 00040 \item[\bf{Amplitude modulation information}] This is given through two functions $\hat{a}$ and $\hat{b}$, which are derived from the beam-pattern functions $F_{+}$ and $F_{\times}$. 00041 \end{description} 00042 Given these, the F statistic in the $b^{th}$ frequency bin is 00043 \begin{equation} 00044 \mathcal{F}_{b} = \frac{4}{S_{h}(f_{0})T_{0}} \frac{B|\hat{F_{a}}|^{2}+A|F_{b}|^{2} - 2C \Re(F_{a}F_{b}^{*})}{D} 00045 \end{equation} 00046 00047 where 00048 00049 \begin{eqnarray} 00050 \label{e1} 00051 \hat{F_{\hat{a}}}=\sum_{a=0}^{\it{NM-1}} x_{a} \hat{a} e^{-2{\pi}i{\Phi}_{ab}(\vec{\lambda})} \\ 00052 \hat{F_{\hat{b}}}=\sum_{a=0}^{\it{NM-1}} x_{a} \hat{b} e^{-2{\pi}i{\Phi}_{ab}(\vec{\lambda})} 00053 \end{eqnarray} 00054 $T_{0}$ is the observation time, $S_{h}$ is the noise power spectral density, and $A$, $B$, $C$, and $D$ are constants. 00055 00056 In writing the previous equation we have assumed that there is a total of $M\cdot N$ data samples and $0\leq a<MN$. $\Phi_{ab}$ is the expected phase at time $a$ for an 00057 intrinsic emission frequency $b\over T_{DeFT}$ (where the denominator is the DeFT time baseline). $\Phi$ 00058 depends on $\vec\lambda$, a vector of parameters that defines the phase model. Typically these are the source location and the spin-down parameter values of the template source for which one is 00059 demodulating. For simplicity, we will focus only on $F_{a}$; the analysis for $F_{b}$ is identical. 00060 Let us now suppose that the time series $x_a$ is composed of $M$ chunks, each of $N$ samples. If we introduce a short-time index $0\leq j<N-1$ and a short time-series index $0\leq \alpha <M-1$, so that $a=N\alpha+j$, we can rewrite the above sum as 00061 \begin{equation} 00062 \hat{F_{\hat{a}}}({\vec{\lambda}})=\sum_{\alpha=0}^{M-1}\sum_{j=0}^{N-1}x_{\alpha j}a_{\alpha j}e^{-2{\pi}i{\Phi}_{ab}(\vec{\lambda})} 00063 \label{e2} 00064 \end{equation} 00065 \noindent Note that $\hat{a}(t)$ is a periodic function with period equal to one sidereal day. Since the sum over $N$ is on a timescale much shorter than that (say, 1 hour), then $\hat{a}(t)$ won't change significantly, and thus can be taken outside of that summation, and then is evaluated at the midpoint of each SFT time. Now, If $\tilde{x}_{\alpha k}$ is the matrix of FTs formed along the short time index $j$ 00066 \begin{equation} 00067 x_{\alpha j}=\frac{1}{N}\sum_{k=0}^{N-1}\tilde{x}_{\alpha k}e^{2\pi{i}\frac{jk}{N}}, 00068 \label{e3} 00069 \end{equation} 00070 \noindent making the appropriate substitutions, Eq.\ref{e1} becomes 00071 \begin{equation} 00072 \hat{F_{\hat{a}}}({\vec{\lambda}})=\sum_{\alpha=0}^{M-1}\hat{a}_{\alpha}\sum_{k=0}^{N-1}\tilde{x}_{\alpha k}\left[\frac{1}{N}\sum_{j=0}^{N-1}e^{-2\pi i(\Phi_{\alpha jb}(\vec{\lambda})-\frac{jk}{N})}\right] 00073 \label{e4} 00074 \end{equation} 00075 We assume that the phase evolution can be described as linear in $t$ during the time duration 00076 $T_{SFT}$; thus we can Taylor-expand $\Phi$ around the temporal midpoint of every SFT time data chunk. For large values of $N$, 00077 the summation over $j$ in eq. (\ref{e4}) can be expressed in closed form, thus saving computations, and eq. (\ref{e4}) can be rewritten as 00078 \begin{equation} 00079 \hat{F_{\hat{a}}}=\sum_{\alpha=0}^{M-1}\hat{a}_{\alpha}e^{i y_\alpha}\sum_{k=0}^{N-1}\tilde{x}_{\alpha\beta} P_{\alpha k}(b,\vec{\lambda}), 00080 \label{DeFT2} 00081 \end{equation} 00082 with 00083 \begin{eqnarray} 00084 \label{DeFT_defs} 00085 P_{\alpha k}(b,\vec{\lambda})={\sin{x'}\over x'}-i{1-\cos{x'}\over x'}\\ 00086 x'=\sum_{s} f_s B_{s\alpha} - k\\ 00087 y_\alpha=\sum_{s} f_s A_{s\alpha}. 00088 \end{eqnarray} 00089 In the previous expressions $f_s$ indicate the spin-down parameters of different orders (labeled 00090 by the index $s$\footnote{Note that when $s=0$ the values computed are coefficients of the intrinsic frequency and thus must be computed for the value corresponding to the index $b$.}), and $A_{s\alpha}$ and $B_{s\alpha}$ 00091 are functions that depend on the phase evolution, whose values depend on $\alpha$ and on $\vec\lambda$. The values of these functions are calculated by the \verb@ComputeSky()@ routine, also in this package. Incidentally, in the code, these are the values contained in the variable \verb@skyConst@. 00092 Note that the function $P_{\alpha k}$ is peaked around $x'=0$. Thus in the summation 00093 over $k$ in eq. (\ref{DeFT2}) one only needs to consider a few values (NTERMS) of $k$ around $k^*$ such 00094 that $x'(k^*)\approx 0$. This approximation again saves computations. Eq. (\ref{DeFT2}) can then be rewritten as 00095 \begin{equation} 00096 \label{DeFT_algo} 00097 \hat{F_{\hat{a}}}=\sum_{\alpha=0}^{M-1}\hat{a}_{\alpha}e^{i y_\alpha}\sum_{k=k^*\pm NTERMS} \tilde x_{\alpha\beta} 00098 P_{\alpha k}(b,\vec{\lambda}). 00099 \end{equation} 00100 If $NTERMS$ is 8 the power loss due to this approximation is less than $\sim 5\%$. 00101 00102 Now, computing $\hat{F_{\hat{a}}}$ and $\hat{F_{\hat{b}}}$ can be done in parallel; given the approximations we have made, for each iteration of the $\alpha$ loop, one computes first $P_{\alpha k}$ (through the k-loop), multiplies by $\tilde{x}_{\alpha k}$, and then forms the statistics of \ref{e1} at the same time. After all the iterations of the $\alpha$ loop are complete, that is, when all SFTs have been exhausted, the final statistic is computed. 00103 00104 </lalLaTeX> */ 00105 00106 00107 #ifndef _LALDEMOD_H 00108 #define _LALDEMOD_H 00109 00110 #include <lal/LALDatatypes.h> 00111 #include <lal/LALComputeAM.h> 00112 00113 #ifdef __cplusplus 00114 extern "C" { 00115 #endif 00116 00117 NRCSID (LALDEMODH, "$Id: LALDemod.h,v 1.21 2007/06/08 14:41:50 bema Exp $"); 00118 00119 /********************************************************** <lalLaTeX> 00120 \subsection*{Error codes} 00121 </lalLaTeX> 00122 ***************************************************** <lalErrTable> */ 00123 #define LALDEMODH_ENULL 1 00124 00125 #define LALDEMODH_MSGENULL "Arguments contained an unexpected null pointer" 00126 00127 /*************************************************** </lalErrTable> */ 00128 00129 #define SMALL 0.000000001 00130 00131 /* <lalLaTeX> 00132 00133 \subsection*{Types} 00134 00135 \subsubsection*{Structure \texttt{DemodPar}} 00136 \idx[Type]{DemodPar} 00137 00138 \noindent This structure contains the parameters for the demodulation routine. The parameters are: 00139 00140 \begin{description} 00141 00142 \item[\texttt{INT4 spinDwnOrder}] Maximum order of spdwn parameter 00143 \item[\texttt{REAL8 *skyConst}] The array of sky constants. 00144 \item[\texttt{REAL8 *spinDwn}] The set of template spindown parameters. 00145 \item[\texttt{AMCoeffs *amcoe}] The values of the function $a$ and $b$, plus their scalar products. 00146 \item[\texttt{REAL8 f0}] The minimum search frequency 00147 \item[\texttt{REAL8 df}] The search frequency spacing 00148 \item[\texttt{INT4 SFTno}] The number of SFTs in coherent timescale 00149 \item[\texttt{INT4 Dterms}] Terms used in the computation of the dirichlet kernel 00150 \item[\texttt{INT4 ifMin}] The index of the minimum frequency of the SFT frequency band. 00151 \item[\texttt{INT4 imax}] How many frequencies are serached. 00152 \item[\texttt{BOOLEAN returnFaFb}] Wether or not to include the values Fa/Fb in the return-structure Fstat. 00153 \end{description} 00154 00155 00156 \subsubsection*{Structure \texttt{LALFstat}} 00157 \idx[Type]{LALFstat} 00158 00159 \noindent This structure contains the results from LALDemod: either 00160 only the value of the $\mathcal{F}$-statistic $F$, or also the values 00161 of the individual "filters" $F_a$ and $F_b$, depending on the 00162 \texttt{DemodPar->returnFaFb}. \\ 00163 \emph{NOTE:} the memory has to be allocated before calling \texttt{LALDemod()}. 00164 00165 \begin{description} 00166 \item[\texttt{REAL8 *F}] Array of values of the $\mathcal{F}$ statistic. 00167 \item[\texttt{COMPLEX16 *Fa}] Results of match filter with $a(t)$. 00168 \item[\texttt{COMPLEX16 *Fb}] Results of match filter with $b(t)$. 00169 \end{description} 00170 00171 00172 </lalLaTeX> */ 00173 00174 00175 /* PARAMETERS */ 00176 typedef struct DemodParTag{ 00177 INT4 spinDwnOrder; /* Maximum order of spdwn parameter */ 00178 REAL8 *skyConst; /* Constants computed in ComputeSky.c */ 00179 REAL8 *spinDwn; /* Spindown parameter set */ 00180 AMCoeffs *amcoe; /*Amplitude Modulation coefficients */ 00181 REAL8 f0; /*Starting Frequency to be demodulated*/ 00182 REAL8 df; /*Frequency index resolution*/ 00183 INT4 SFTno; /* No. of SFTs*/ 00184 INT4 Dterms; /*Terms used in the computation of the dirichlet kernel*/ 00185 INT4 ifmin; /*smallest frequency index in SFTs */ 00186 INT4 imax; /*maximum # of values of F to calculate */ 00187 BOOLEAN returnFaFb; /* wether or not to include the values Fa/Fb in the return LALFstat */ 00188 }DemodPar; 00189 00190 00191 typedef struct { 00192 REAL8 *F; /* Array of value of the F statistic */ 00193 COMPLEX16 *Fa; /* Results of match filter with a(t) */ 00194 COMPLEX16 *Fb; /* Results of match filter with b(t) */ 00195 } LALFstat; 00196 00197 00198 00199 /*This structure will hold a single FFT*/ 00200 typedef struct FFTTag 00201 { 00202 COMPLEX8FrequencySeries *fft; 00203 } FFT; 00204 00205 /********************************************************** <lalLaTeX> 00206 \vfill{\footnotesize\input{LALDemodHV}} 00207 \newpage\input{LALDemodC} 00208 ******************************************************* </lalLaTeX> */ 00209 00210 /* Function prototypes */ 00211 00212 void LALDemod (LALStatus *status, LALFstat *Fstat, FFT **input, DemodPar *params); 00213 void LALDemodFAST (LALStatus *status, LALFstat *Fstat, FFT **input, DemodPar *params); 00214 00215 00216 /* <lalLaTeX> 00217 \newpage\input{LALDemodTestC} 00218 </lalLaTeX> */ 00219 00220 #ifdef __cplusplus 00221 } 00222 #endif 00223 #endif /* _LALDEMOD_H */
1.5.2