LALPulsar  6.1.0.1-fe68b98
NDParamPLUT.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005 Badri Krishnan, Alicia Sintes
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  *
22  * File Name: NDParamPLUT.c
23  *
24  * Authors: Sintes, A.M., Krishnan, B.,
25  *
26  *
27  * History: Created by Sintes May 15, 2001
28  * Modified by Badri Krishnan Feb 2003
29  *
30  *-----------------------------------------------------------------------
31  *
32  * NAME
33  * NDParamPLUT.c
34  *
35  * SYNOPSIS
36  *
37  * DESCRIPTION
38  *
39  * DIAGNOSTICS
40  *
41  *-----------------------------------------------------------------------
42  */
43 
44 /**
45  * \author Sintes, A. M. and Krishnan, B.
46  * \file
47  * \ingroup LUT_h
48  * \brief Function that calculates the parameters needed for generating the look-up-table.
49  *
50  * ### Description ###
51  *
52  * This routine calculates the parameters needed for generating the look-up-table.
53  * It is valid for all cases in which the Hough transform
54  * master equation is of the form:
55  * \f$ f(t) \f$ -\c f0 = \f$ \vec\xi \cdot \hat n \f$ , or
56  * equivalently,
57  * \f$ \cos(\phi) \f$ = ( \f$ f(t)- \f$ \c f0)/ \f$ \vert\vec\xi\vert \f$ .
58  * \f$ \vec\xi \f$ , hereafter \c xi, is calculated according to the demodulation procedure used in a
59  * first stage.\\
60  *
61  * ### Uses ###
62  *
63  * \code
64  * LALRotatePolarU()
65  * \endcode
66  *
67  */
68 
69 
70 #include <lal/LUT.h>
71 
73  HOUGHParamPLUT *out, /* parameters needed build LUT*/
74  HOUGHSizePar *size,
75  HOUGHDemodPar *par ) /* demodulation parameters */
76 {
77 
78  /* --------------------------------------------- */
79 
80  REAL8 f0; /* frequency corresponding to f0Bin */
81  INT8 f0Bin;
82  REAL8 deltaF; /* df=1/TCOH */
83  REAL8 delta;
84  REAL8 vFactor;
85  REAL8 xiX, xiY, xiZ;
86  REAL8 modXi, invModXi;
87  REAL8UnitPolarCoor xiInit;
88  UINT4 spinOrder, i;
89  REAL8 *spinF;
90  REAL8 timeDiff; /* T(t)-T(t0) */
91  REAL8 timeDiffProd;
92  REAL8 freqOffset;
93  INT4 offset;
94  /* --------------------------------------------- */
95 
96  INITSTATUS( status );
98 
99  /* Make sure the arguments are not NULL: */
103 
104  /* Make sure f0Bin is not zero: */
105  f0Bin = size->f0Bin;
107 
108  out->f0Bin = f0Bin;
109  deltaF = out->deltaF = size->deltaF;
110 
111  f0 = f0Bin * deltaF;
112 
113  out->epsilon = size->epsilon;
114  out->nFreqValid = size->nFreqValid;
115  /* ------------------------------------------- */
116 
117 
118  /* ------------------------------------------- */
119  /* *********** xi calculation ***************** */
120 
121  vFactor = f0;
122 
123  spinOrder = par->spin.length;
124 
125  if ( spinOrder ) {
126  ASSERT( par->spin.data, status, LUTH_ENULL, LUTH_MSGENULL );
127  timeDiff = par->timeDiff;
128  timeDiffProd = 1.0;
129  spinF = par->spin.data;
130 
131  for ( i = 0; i < spinOrder; ++i ) {
132  timeDiffProd *= timeDiff;
133  vFactor += spinF[i] * timeDiffProd;
134  }
135  }
136 
137  xiX = vFactor * ( par->veloC.x );
138  xiY = vFactor * ( par->veloC.y );
139  xiZ = vFactor * ( par->veloC.z );
140 
141  /* ------------------------------------------- */
142  /* ***** convert xi into Polar coordinates ***** */
143 
144  modXi = sqrt( xiX * xiX + xiY * xiY + xiZ * xiZ );
145  /* for testing we used: modXi = F0* 1.06e-4; */
146  invModXi = 1. / modXi;
147 
148  xiInit.delta = asin( xiZ * invModXi );
149  /* the arc sine is in the interval [-pi/2,pi/2] */
150 
151  if ( xiX || xiY ) {
152  xiInit.alpha = atan2( xiY, xiX );
153  } else {
154  xiInit.alpha = 0.0;
155  }
156 
157  /* if( (xiX == 0.0 ) && (xiY == 0.0 ) ){ */
158  /* xiInit.alpha = 0.0; */
159  /* }else{ xiInit.alpha = atan2(xiY, xiX); } */
160 
161  /* ------------------------------------------- */
162  /* **** Rotate Patch, so that its center becomes */
163  /* **** the south pole {x,y,z} = {0,0,-1} ***** */
164  /* Calculate xi in the new coordinate system. */
165 
166  TRY( LALRotatePolarU( status->statusPtr,
167  &( *out ).xi, &xiInit, &( *par ).skyPatch ), status );
168 
169  /* ------------------------------------------- */
170  delta = out->xi.delta;
171  out->cosDelta = deltaF * invModXi;
172 
173 
174  freqOffset = -modXi * sin( delta );
175  offset = out->offset = floor( 0.5 + freqOffset / deltaF );
176  out->cosPhiMax0 = invModXi * ( offset + 0.5 ) * deltaF;
177  out->cosPhiMin0 = invModXi * ( offset - 0.5 ) * deltaF;
178 
179 
180  /* ------------------------------------------- */
181 
183 
184  /* normal exit */
185  RETURN( status );
186 }
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
200 
201 
static double double delta
#define TRY(func, statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
double REAL8
int64_t INT8
uint32_t UINT4
int32_t INT4
void LALRotatePolarU(LALStatus *status, REAL8UnitPolarCoor *out, REAL8UnitPolarCoor *in, REAL8UnitPolarCoor *par)
Definition: Stereographic.c:97
void LALNDHOUGHParamPLUT(LALStatus *status, HOUGHParamPLUT *out, HOUGHSizePar *size, HOUGHDemodPar *par)
Definition: NDParamPLUT.c:72
#define LUTH_MSGENULL
Definition: LUT.h:157
#define LUTH_EFREQ
Definition: LUT.h:154
#define LUTH_ENULL
Definition: LUT.h:149
#define LUTH_MSGEFREQ
Definition: LUT.h:162
size
out
int deltaF
Demodulation parameters needed for the Hough transform; all coordinates are assumed to be with respec...
Definition: LUT.h:353
Parameters needed to construct the partial look up table.
Definition: LUT.h:333
required for constructing patch
Definition: LUT.h:294
Polar coordinates of a unitary vector on the sphere.
Definition: LUT.h:327
REAL8 alpha
any value
Definition: LUT.h:328
REAL8 delta
In the interval [ ].
Definition: LUT.h:329