Loading [MathJax]/extensions/TeX/AMSsymbols.js
LALPulsar 7.1.1.1-5e288d3
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
PatchGrid.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: PatchGrid.c
23 *
24 * Authors: Sintes, A.M., Krishnan, B.
25 *
26 *
27 * History: Created by Sintes May 14, 2001
28 * Modified by Badri Krishnan Feb 2003
29 * Modified by Sintes May 2003
30 *
31 *-----------------------------------------------------------------------
32 *
33 * NAME
34 * PatchGrid.c
35 *
36 * SYNOPSIS
37 *
38 * DESCRIPTION
39 *
40 * DIAGNOSTICS
41 *
42 *-----------------------------------------------------------------------
43 */
44
45/**
46 * \author Alicia Sintes, Badri Krishnan
47 * \file
48 * \ingroup LUT_h
49 * \brief Function for tiling the sky-patch (on the projected plane).
50 *
51 * ### Description ###
52 *
53 * This is a \c provisionalfinal now ? routine for tiling a sky-pacth
54 * on the projected plane.
55 *
56 * Patch size specified by user
57 *
58 * == doc needs to be updated ==
59 *
60 * The reason to call it \c provisional is because
61 * the size of the patch depends on the grid used in the
62 * demodulation stage. Neighbour sky-patches should not be separated
63 * nor overlapping too much.
64 * Here for setting the patch size, we consider only \f$ v_{epicycle} \f$ ,
65 * the frequency \c f0 and \c deltaF so that the ` longitudinal' size
66 * of the patch is given by <tt>side == deltaF/f0 * c/v_epi</tt>.
67 * By taking \c f0 to be the maximun frequency considered in that step,
68 * the patch-size is valid for a whole frequency range.\ \
69 *
70 * Given input parameters, the function LALHOUGHPatchGrid() provides
71 * patch information.
72 *
73 * The input <tt>*in1</tt> is a structure of type \c HOUGHResolutionPar containing
74 * some resolution parameters such as:
75 * <tt>in1->f0</tt> a frequency, <tt>in1->deltaF</tt> the frequency resolution, and
76 * <tt>in1->minWidthRatio</tt> the ratio between the minimum annulus width
77 * for this search and the minimun annulus width for 1 year integration time.
78 * This value should be in the interval [1.0, 25.0].
79 *
80 */
81
82
83#include <lal/LUT.h>
84
85
86/*
87 * The functions that make up the guts of this module
88 */
89
90/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
91
92void LALHOUGHComputeSizePar( LALStatus *status, /* demodulated case */
93 HOUGHSizePar *out,
95 )
96{
97
98
99 INT8 f0Bin; /* corresponding freq. bin */
100 REAL8 deltaF; /* frequency resolution df=1/TCOH*/
101 REAL8 pixelFactor; /* number of pixel that fit in the thinnest annulus*/
102 REAL8 pixErr; /* for validity of LUT as PIXERR */
103 REAL8 linErr; /* as LINERR circle ->line */
104 REAL8 vTotC; /* estimate value of v-total/C as VTOT */
105
106 REAL8 deltaX; /* pixel size in the projected plane */
107 REAL8 deltaY;
108 UINT2 xSide; /* number of pixels in the x direction (projected plane)*/
109 UINT2 ySide; /* number of pixels in the y direction */
110 UINT2 maxSide; /* number of pixels in the y direction */
111
112 UINT2 maxNBins; /* maximum number of bins affecting the patch. For
113 memory allocation */
114 REAL8 patchSizeX; /* size of sky patch projected */
115 REAL8 patchSizeY; /* size of sky patch prijected */
116 REAL8 patchSkySizeX; /* Size of sky patch in radians */
117 REAL8 patchSkySizeY;
118
119 /* --------------------------------------------- */
122
123 /* Make sure the arguments are not NULL: */
126
127 patchSkySizeX = in1->patchSkySizeX;
128 patchSkySizeY = in1->patchSkySizeY;
129
130 /* Make sure the user chose a sky patch smaller that pi of the sky */
131 ASSERT( patchSkySizeX > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
132 ASSERT( patchSkySizeX <= LAL_PI, status, LUTH_EVAL, LUTH_MSGEVAL );
133 ASSERT( patchSkySizeY > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
134 ASSERT( patchSkySizeY <= LAL_PI, status, LUTH_EVAL, LUTH_MSGEVAL );
135
136 pixelFactor = in1->pixelFactor;
137 pixErr = in1->pixErr;
138 linErr = in1->linErr;
139
140 /* Make sure the parameters make sense */
141 ASSERT( pixelFactor > 0, status, LUTH_EVAL, LUTH_MSGEVAL );
142 ASSERT( pixErr < 1.0, status, LUTH_EVAL, LUTH_MSGEVAL );
143 ASSERT( linErr < 1.0, status, LUTH_EVAL, LUTH_MSGEVAL );
144 ASSERT( pixErr > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
145 ASSERT( linErr > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
146
147 f0Bin = in1->f0Bin;
148 deltaF = in1->deltaF;
149 vTotC = in1->vTotC;
150
151 ASSERT( f0Bin > 0, status, LUTH_EVAL, LUTH_MSGEVAL );
153 ASSERT( vTotC > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
154 ASSERT( vTotC < 0.001, status, LUTH_EVAL, LUTH_MSGEVAL );
155
156 /* ************ THIS IS FOR THE DEMODULATED CASE ONLY *********** */
157 out->deltaF = deltaF;
158 out->f0Bin = f0Bin;
159
160 deltaX = deltaY = 1.0 / ( vTotC * pixelFactor * f0Bin );
161 out->deltaX = deltaX;
162 out->deltaY = deltaY;
163
164 patchSizeX = 4.0 * tan( 0.25 * patchSkySizeX );
165 patchSizeY = 4.0 * tan( 0.25 * patchSkySizeY );
166 xSide = out->xSide = ceil( patchSizeX / deltaX );
167 ySide = out->ySide = ceil( patchSizeY / deltaY );
168 maxSide = MAX( xSide, ySide );
169
170 /* the max number of bins that can fit in the diagonal and a bit more
171 1.41->1.5 */
172 maxNBins = out->maxNBins = ceil( ( 1.5 * maxSide ) / pixelFactor );
173
174 /* maximum number of borders affecting the patch +1. Each Bin has up to 4
175 borders, but they are common (they share 2 with the next bin). Depending on
176 the orientation could be equal to maxNBins. In other cases twice maxNBins.
177 Here we are very conservative*/
178
179 out->maxNBorders = 1 + 2 * maxNBins;
180
181 /* LUT validity */
182 /* From equation: nFreqValid = pixErr/(pixelFactor* vTotC * 0.5 * maxSide * deltaX);
183 or the same is */
184 out->nFreqValid = ( pixErr * 2 * f0Bin ) / ( pixelFactor * maxNBins );
185
186 /* max. angle (rad.) from the pole to consider a circle as a line in the projected plane */
187 /* epsilon ~ 2/radius circle; radius ~h*h/(2b), epsilon = 4b/(h*h) */
188
189 out->epsilon = 8.0 * linErr / ( maxSide * deltaX * maxSide ) ;
190
191 /* ------------------------------------------- */
192
193
195
196 /* normal exit */
197 RETURN( status );
198}
199
200
201
202/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
203
204void LALHOUGHComputeNDSizePar( LALStatus *status, /* non-demod. case */
205 HOUGHSizePar *out,
207 )
208{
209
210 INT8 f0Bin; /* corresponding freq. bin */
211 REAL8 deltaF; /* frequency resolution df=1/TCOH*/
212 REAL8 pixelFactor; /* number of pixel that fit in the thinnest annulus*/
213 REAL8 pixErr; /* for validity of LUT as PIXERR */
214 REAL8 linErr; /* as LINERR circle ->line */
215 REAL8 vTotC; /* estimate value of v-total/C as VTOT */
216
217 REAL8 deltaX; /* pixel size in the projected plane */
218 REAL8 deltaY;
219 UINT2 xSide; /* number of pixels in the x direction (projected plane)*/
220 UINT2 ySide; /* number of pixels in the y direction */
221 UINT2 maxDopplerBin;
222 UINT2 maxSide; /* number of pixels in the y direction */
223
224 UINT2 maxNBins1, maxNBins2;
225 UINT2 maxNBins; /* maximum number of bins affecting the patch. For
226 memory allocation */
227 REAL8 patchSizeX; /* size of sky patch projected */
228 REAL8 patchSizeY; /* size of sky patch prijected */
229 REAL8 patchSkySizeX; /* Size of sky patch in radians */
230 REAL8 patchSkySizeY;
231
232 /* --------------------------------------------- */
235
236 /* Make sure the arguments are not NULL: */
239
240 patchSkySizeX = in1->patchSkySizeX;
241 patchSkySizeY = in1->patchSkySizeY;
242
243 /* Make sure the user chose a sky patch smaller that pi of the sky */
244 ASSERT( patchSkySizeX > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
245 ASSERT( patchSkySizeX <= LAL_PI, status, LUTH_EVAL, LUTH_MSGEVAL );
246 ASSERT( patchSkySizeY > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
247 ASSERT( patchSkySizeY <= LAL_PI, status, LUTH_EVAL, LUTH_MSGEVAL );
248
249 pixelFactor = in1->pixelFactor;
250 pixErr = in1->pixErr;
251 linErr = in1->linErr;
252
253 /* Make sure the parameters make sense */
254 ASSERT( pixErr < 1.0, status, LUTH_EVAL, LUTH_MSGEVAL );
255 ASSERT( linErr < 1.0, status, LUTH_EVAL, LUTH_MSGEVAL );
256 ASSERT( pixErr > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
257 ASSERT( linErr > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
258
259 f0Bin = in1->f0Bin;
260 deltaF = in1->deltaF;
261 vTotC = in1->vTotC;
262
263 ASSERT( f0Bin > 0, status, LUTH_EVAL, LUTH_MSGEVAL );
265 ASSERT( vTotC > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
266 ASSERT( vTotC < 0.001, status, LUTH_EVAL, LUTH_MSGEVAL );
267
268 /* ************ THIS IS FOR THE *NON* DEMODULATED CASE ONLY *********** */
269 out->deltaF = deltaF;
270 out->f0Bin = f0Bin;
271
272 deltaX = deltaY = 1.0 / ( vTotC * pixelFactor * f0Bin );
273 out->deltaX = deltaX;
274 out->deltaY = deltaY;
275
276 patchSizeX = 4.0 * tan( 0.25 * patchSkySizeX );
277 patchSizeY = 4.0 * tan( 0.25 * patchSkySizeY );
278 xSide = out->xSide = ceil( patchSizeX / deltaX );
279 ySide = out->ySide = ceil( patchSizeY / deltaY );
280 maxSide = MAX( xSide, ySide );
281
282 /* the max number of bins that can fit in the full sky */
283 maxDopplerBin = floor( f0Bin * vTotC + 0.5 );
284 maxNBins1 = 1 + 2 * maxDopplerBin;
285
286 /* estimate of the max number of bins that can fit in the patch
287 (over-estimated) as the max number of bins that can fit in the diagonal
288 and a bit more 1.41->1.5 */
289 maxNBins2 = ceil( ( 1.5 * maxSide ) / pixelFactor );
290
291 maxNBins = out->maxNBins = MIN( maxNBins1, maxNBins2 );
292
293 /* maximum number of borders affecting the patch +1. Each Bin has up to 4
294 borders, but they are common (they share 2 with the next bin). Depending on
295 the orientation could be equal to maxNBins. In other cases twice maxNBins.
296 Here we are very conservative*/
297
298 out->maxNBorders = 1 + 2 * maxNBins;
299
300 /* LUT validity */
301 if ( maxDopplerBin < 2 ) {
302 /* the answer is infinity more or less */
303 out->nFreqValid = f0Bin;
304 } else {
305 REAL8 num, den;
306 num = maxDopplerBin * maxDopplerBin;
307 den = ( maxDopplerBin - 1 ) * ( maxDopplerBin - 1 );
308 out->nFreqValid = pixErr / ( pixelFactor * vTotC ) * sqrt( num / den - 1.0 );
309 }
310
311 /* max. angle (rad.) from the pole to consider a circle as a line in the projected plane */
312 /* epsilon ~ 2/radius circle; radius ~h*h/(2b), epsilon = 4b/(h*h) */
313
314 out->epsilon = 8.0 * linErr / ( maxSide * deltaX * maxSide ) ;
315
316 /* ------------------------------------------- */
317
318
320
321 /* normal exit */
322 RETURN( status );
323}
324
325
326
327
328
329/* >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< */
330
332 HOUGHPatchGrid *out, /* */
333 HOUGHSizePar *in1 )
334{
335
336 REAL8 deltaX;
337 REAL8 deltaY;
338 UINT2 xSide; /* number of pixels in the x direction (projected plane)*/
339 UINT2 ySide; /* number of pixels in the y direction */
340
341 INT4 i;
342 REAL8 xMin, xMax, x1;
343 REAL8 yMin, yMax, myy1;
344 REAL8 *xCoord;
345 REAL8 *yCoord;
346 /* --------------------------------------------- */
347
350
351 /* Make sure the arguments are not NULL: */
356
357 xCoord = out->xCoor;
358 yCoord = out->yCoor;
359
360 xSide = out->xSide;
361 ySide = out->ySide;
362
363 /* Make sure there are physical pixels in that patch */
366
367 deltaX = out->deltaX = in1->deltaX;
368 deltaY = out->deltaY = in1->deltaY;
369
370 /* Make sure pixel sizes are positive definite */
371 ASSERT( deltaX > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
372 ASSERT( deltaY > 0.0, status, LUTH_EVAL, LUTH_MSGEVAL );
373
374 out->f0 = in1->f0Bin * in1->deltaF;
375 out->deltaF = in1->deltaF;
376
377 /* ------------------------------------------- */
378 /* Calculation of the patch limits with respect to the centers of the
379 last pixels. Note xSide and ySide are integers */
380 xMax = out->xMax = deltaX * 0.5 * ( xSide - 1 );
381 yMax = out->yMax = deltaY * 0.5 * ( ySide - 1 );
382
383 xMin = out->xMin = -xMax;
384 yMin = out->yMin = -yMax;
385
386 /* ------------------------------------------- */
387
388 /* Coordiantes of the pixel centers, in the projected plane */
389 x1 = xMin;
390 for ( i = 0; i < xSide; ++i ) {
391 xCoord[i] = x1;
392 x1 += deltaX;
393 }
394
395 myy1 = yMin;
396 for ( i = 0; i < ySide; ++i ) {
397 yCoord[i] = myy1;
398 myy1 += deltaY;
399 }
400
401 /* ------------------------------------------- */
402
404
405 /* normal exit */
406 RETURN( status );
407}
#define MAX(x, y)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define MIN(x, y)
Definition: dumpSFT.c:39
#define LAL_PI
double REAL8
int64_t INT8
uint16_t UINT2
int32_t INT4
#define LUTH_MSGENULL
Definition: LUT.h:157
#define LUTH_EVAL
Definition: LUT.h:155
#define LUTH_ENULL
Definition: LUT.h:149
void LALHOUGHComputeNDSizePar(LALStatus *status, HOUGHSizePar *out, HOUGHResolutionPar *in1)
Definition: PatchGrid.c:204
void LALHOUGHFillPatchGrid(LALStatus *status, HOUGHPatchGrid *out, HOUGHSizePar *in1)
Definition: PatchGrid.c:331
#define LUTH_MSGEVAL
Definition: LUT.h:163
void LALHOUGHComputeSizePar(LALStatus *status, HOUGHSizePar *out, HOUGHResolutionPar *in1)
Definition: PatchGrid.c:92
out
int deltaF
This structure stores patch-frequency grid information.
Definition: LUT.h:264
parameters needed for gridding the patch
Definition: LUT.h:282
REAL8 deltaF
Frequency resolution: df=1/TCOH
Definition: LUT.h:284
REAL8 pixErr
for validity of LUT as PIXERR
Definition: LUT.h:288
INT8 f0Bin
Frequency bin at which construct the grid.
Definition: LUT.h:283
REAL8 patchSkySizeY
Patch size in radians along y-axis.
Definition: LUT.h:286
REAL8 patchSkySizeX
Patch size in radians along x-axis.
Definition: LUT.h:285
REAL8 pixelFactor
number of pixel that fit in the thinnest annulus
Definition: LUT.h:287
REAL8 vTotC
estimate value of v-total/C as VTOT
Definition: LUT.h:290
REAL8 linErr
as LINERR circle ->line
Definition: LUT.h:289
required for constructing patch
Definition: LUT.h:294
INT8 f0Bin
corresponding freq bin
Definition: LUT.h:295
REAL8 deltaY
Definition: LUT.h:298
REAL8 deltaF
df=1/TCOH
Definition: LUT.h:296
REAL8 deltaX
pixel size in the projected plane
Definition: LUT.h:297