LALInspiral 5.0.3.1-eeff03c
LALInspiralWaveNormalise.c
Go to the documentation of this file.
1/*
2* Copyright (C) 2007 David Churches, B.S. Sathyaprakash
3*
4* This program is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License as published by
6* the Free Software Foundation; either version 2 of the License, or
7* (at your option) any later version.
8*
9* This program is distributed in the hope that it will be useful,
10* but WITHOUT ANY WARRANTY; without even the implied warranty of
11* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12* GNU General Public License for more details.
13*
14* You should have received a copy of the GNU General Public License
15* along with with program; see the file COPYING. If not, write to the
16* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17* MA 02110-1301 USA
18*/
19
20/**
21 * \author Sathyaprakash, B. S.
22 * \file
23 *
24 * \brief Module to find the norm of a signal and to return a normalised
25 * array. The original signal is left untouched.
26 *
27 * ### Prototypes ###
28 *
29 * <tt>LALInspiralWaveNormalise()</tt>
30 *
31 * ### Description ###
32 *
33 * Given the positive frequency Fourier components
34 * \f$H_k,\f$ \f$k=0,\ldots,n-1,\f$ of a vector
35 * and the noise PSD \f$S_m,\f$ \f$m=0,\ldots,n/2,\f$
36 * this module first computes the norm \f$H\f$ of the vector treating
37 * \f$S_m\f$ as the measure:
38 * (note that in {\em fftw} notation, the zeroth frequency
39 * component is \f$H_0,\f$ Nyquist
40 * is \f$H_{n/2},\f$ \f$H_k,\f$ \f$k \ne 0,n/2,\f$ (\f$H_{n-k})\f$ is the real (imaginary)
41 * part of the \f$k\f$th harmonic)
42 * \f{equation}{
43 * \label{eq_inspiralnorm}
44 * H = \sum_{k=1}^{n/2-1} \frac{H_k^2 + H^2_{n-k}}{S_k}.
45 * \f}
46 * (Note that the zeroth and Nyquist components are ignored in the
47 * computation of the norm.)
48 * It then replaces the original vector \f$H_k\f$ with normalized
49 * vector using:
50 * \f{equation}{
51 * \widehat H_k = \frac {H_k}{\sqrt H},\ \ k=0,\ldots n-1.
52 * \f}
53 *
54 * ### Algorithm ###
55 *
56 *
57 * ### Uses ###
58 *
59 * \code
60 * none.
61 * \endcode
62 *
63 * ### Notes ###
64 *
65 */
66#include <lal/LALNoiseModelsInspiral.h>
67#include <lal/LALNoiseModels.h>
68
69void
71 (
73 REAL4Vector *in,
74 REAL8 *norm,
75 REAL8Vector psd
76 )
77{
78
79 INT4 i, n, nby2, k;
80 REAL8 psdvalue;
81
84
85 ASSERT (in->data, status, LALNOISEMODELSH_ENULL, LALNOISEMODELSH_MSGENULL);
86 ASSERT (psd.data, status, LALNOISEMODELSH_ENULL, LALNOISEMODELSH_MSGENULL);
87 ASSERT (psd.length == in->length/2+1, status, LALNOISEMODELSH_ESIZE, LALNOISEMODELSH_MSGESIZE);
88
89 n = in->length;
90 *norm = 0;
91 nby2 = n/2;
92
93 for (i=1; i<nby2; i++)
94 {
95 k = n-i;
96 psdvalue = psd.data[i];
97 if (psdvalue)
98 {
99 *norm += (in->data[i]*in->data[i] + in->data[k]*in->data[k])/psdvalue;
100 }
101 }
102
103 /* If we want to add the negative frequency components as well now is
104 * the time to do that before 0th and Nyquist contributions are added
105 */
106
107 *norm *= 2.;
108
109 /*
110 if (psd.data[nby2]) *norm += pow(in->data[nby2], 2.)/psd.data[nby2];
111 if (psd.data[0]) *norm += pow(in->data[0], 2.)/psd.data[0];
112 */
113 /* Set the 0th and Nyquist frequency bins to be zero. */
114 in->data[0] = in->data[nby2] = 0.;
115
116 *norm = sqrt(*norm);
117
118 for (i=0; i<n; i++)
119 {
120 *(in->data+i) /= *norm;
121 }
122
124 RETURN(status);
125}
void LALInspiralWaveNormalise(LALStatus *status, REAL4Vector *in, REAL8 *norm, REAL8Vector psd)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
double i
double REAL8
int32_t INT4
#define LALNOISEMODELSH_ENULL
#define LALNOISEMODELSH_ESIZE
int n
REAL4 * data
REAL8 * data