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
Peak2PHMD.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 * History: Created by Sintes June 20, 2001
23 * Modified...
24 *
25 *
26*/
27
28#include <lal/PHMD.h>
29
30
31/**
32 * \author Sintes, A. M.
33 * \brief Construction of Partial-Hough-Map-Derivatives (\c phmd) given a peak-gram and the look-up-table.
34 * \ingroup PHMD_h
35 *
36 * ### Description ###
37 *
38 * This routine produces a \c phmd at a certain frequency for a given peak-gram and
39 * look-up-table.
40 *
41 * The inputs are:
42 *
43 * <tt>phmd->fBin</tt>: The frequency bin of this \c phmd.
44 *
45 * <tt>*lut</tt>: The look-up-table (of type \c HOUGHptfLUT)
46 *
47 * <tt>*pg</tt>: The peak-gram (of type \c HOUGHPeakGram)
48 *
49 * The function LALHOUGHPeak2PHMD() makes sure that the \c lut, the
50 * peak-gram and also the frequency of the \c phmd
51 * are compatible.
52 *
53 * The output <tt>HOUGHphmd *phmd</tt> is a structure
54 * containing the frequency bin of this \c phmd,
55 * the total number of borders of each type (<em>Left and Right</em>) to be
56 * marked, the pointers to the borders in the corresponding
57 * look-up-table, plus \e border effects of clipping on a finite
58 * patch.
59 *
60 */
62 HOUGHphmd *phmd, /* partial Hough map derivative */
63 HOUGHptfLUT *lut, /* Look up table */
64 HOUGHPeakGram *pg) /* peakgram */
65{
66
67 INT2 i,j;
68 UCHAR *column1P;
69 INT4 fBinDif,shiftPeak,minPeakBin,maxPeakBin,thisPeak;
70 INT2 relatIndex;
71 UINT4 lengthLeft,lengthRight,n, searchIndex;
72 UINT8 firstBin,lastBin,pgI,pgF;
73 /* --------------------------------------------- */
74
77
78/**
79 * lots of error checking of arguments -- asserts have been
80 * replaced by aborts
81 */
82
83 /* Make sure the arguments are not NULL: */
84 if (phmd == NULL) {
85 /* fprintf(stderr,"null pointer found [Peak2PHMD.c %d]\n", __LINE__); */
87 }
88 /* ASSERT (phmd, status, PHMDH_ENULL, PHMDH_MSGENULL); */
89
90 if (lut == NULL) {
91 /* fprintf(stderr,"null pointer found [Peak2PHMD.c %d]\n", __LINE__); */
93 }
94 /* ASSERT (lut, status, PHMDH_ENULL, PHMDH_MSGENULL); */
95
96 if (lut->border == NULL) {
98 }
99
100 if (pg == NULL) {
101 /* fprintf(stderr,"null pointer found [Peak2PHMD.c %d]\n", __LINE__); */
103 }
104 /* ASSERT (pg, status, PHMDH_ENULL, PHMDH_MSGENULL); */
105
106 if (phmd->firstColumn == NULL) {
107 /* fprintf(stderr,"null pointer found [Peak2PHMD.c %d]\n", __LINE__); */
109 }
110 /* ASSERT (phmd->firstColumn, status, PHMDH_ENULL, PHMDH_MSGENULL); */
111
112 /* Make sure there are elements in firstColumn */
113 if (phmd->ySide == 0) {
114 /* fprintf(stderr,"phmd->ySide should be non-zero [Peak2PHMD.c %d]\n", __LINE__); */
116 }
117 /* ASSERT (phmd->ySide, status, PHMDH_ESIZE, PHMDH_MSGESIZE); */
118
119 /* Make sure peakgram and lut have same frequency discretization */
120 if ( fabs((REAL4)lut->deltaF - (REAL4)pg->deltaF) > 1.0e-6) {
122 }
123 /* ASSERT ( fabs((REAL4)lut->deltaF - (REAL4)pg->deltaF) < 1.0e-6, status, PHMDH_EVAL, PHMDH_MSGEVAL); */
124
125 /* Make sure phmd.fBin and lut are compatible */
126 /* case to "long long" to be expected type for llabs() */
127 fBinDif = llabs( (long long)( (phmd->fBin) - (lut->f0Bin) ));
128 if ( fBinDif > lut->nFreqValid ) {
129 /* fprintf(stderr,"fBinDif > nFreqValid [Peak2PHMD.c %d]\n", __LINE__); */
131 }
132 /* ASSERT (fBinDif < lut->nFreqValid, status, PHMDH_EFREQ, PHMDH_MSGEFREQ); */
133
134
135 pgI = pg->fBinIni;
136 pgF = pg->fBinFin;
137 /* bounds of interval to look at in the peakgram */
138 firstBin = (phmd->fBin) + (lut->iniBin) + (lut->offset);
139 lastBin = firstBin + (lut->nBin)-1;
140
141 /* Make sure peakgram f-interval and phmd.fBin+lut are compatible */
142 /* ASSERT ( pgI <= firstBin, status, PHMDH_EINT, PHMDH_MSGEINT); */
143 /* ASSERT ( pgF >= lastBin, status, PHMDH_EINT, PHMDH_MSGEINT); */
144 if ( pgI > firstBin ) {
146 }
147 if ( pgF < lastBin ) {
149 }
150
151
152 /* ------------------------------------------------------------------- */
153 /* initialization */
154 /* ------------------------------------------------------------------- */
155 n= pg->length;
156
157 lengthLeft = 0;
158 lengthRight= 0;
159
160 column1P = &(phmd->firstColumn[0]);
161
162 for(i=0; i< phmd->ySide; ++i ){
163 *column1P = 0;
164 ++column1P;
165 }
166
167 minPeakBin = firstBin - pgI;
168 maxPeakBin = lastBin - pgI;
169
170 /* ------------------------------------------------------------------- */
171 /* ------------------------------------------- */
172 if(n){ /* only if there are peaks present */
173 /* ------------------------------------------- */
174 INT2 lb1,rb1,lb2,rb2;
175 INT2 max1,min1,max2,min2;
176 INT2 nBinPos;
177 UCHAR test1;
178
179 nBinPos = (lut->iniBin) + (lut->nBin) -1;
180 shiftPeak = pgI - (phmd->fBin) - (lut->offset);
181
182 /* ------------------------------------------------------------------- */
183 /* searching for the initial peak to look at */
184 /* ------------------------------------------------------------------- */
185
186 searchIndex = (n * minPeakBin ) /(pgF-pgI+1);
187 if (searchIndex >= n) { searchIndex = n-1;}
188
189 /* moving backwards */
190 /* -----------------*/
191
192 test1=1;
193 while (searchIndex >0 && test1) {
194 if ( pg->peak[searchIndex -1] >= minPeakBin ) {
195 --searchIndex;
196 }
197 else {
198 test1=0;
199 }
200 }
201
202 /* moving forwards */
203 /* -----------------*/
204
205 test1=1;
206 while (searchIndex < n-1 && test1) {
207 if ( pg->peak[searchIndex] < minPeakBin ) {
208 ++searchIndex;
209 }
210 else {
211 test1=0;
212 }
213 }
214
215 /* ------------------------------------------------------------------- */
216 /* for all the interesting peaks (or none) */
217 /* ------------------------------------------------------------------- */
218
219 test1=1;
220
221 while (searchIndex < n && test1) {
222 thisPeak = pg->peak[searchIndex];
223
224 if (thisPeak > maxPeakBin) {
225 test1=0;
226 } else {
227 if ( thisPeak >= minPeakBin) { /* we got a peak */
228 /* relative Index */
229 relatIndex = thisPeak + shiftPeak;
230
231 i = relatIndex;
232 if( relatIndex < 0 ) i = nBinPos - relatIndex;
233
234
235 if ( i >= lut->nBin ) {
236 fprintf(stderr,"current index i=%d not lesser than nBin=%d\n [Peak2PHMD.c %d]\n", i,lut->nBin, __LINE__);
237 }
238
239
240 /* Reading the bin information */
241 lb1 = lut->bin[i].leftB1;
242 rb1 = lut->bin[i].rightB1;
243 lb2 = lut->bin[i].leftB2;
244 rb2 = lut->bin[i].rightB2;
245
246 max1 = lut->bin[i].piece1max;
247 min1 = lut->bin[i].piece1min;
248 max2 = lut->bin[i].piece2max;
249 min2 = lut->bin[i].piece2min;
250
251 /* border selection from lut */
252
253 if(lb1){
254 phmd->leftBorderP[lengthLeft] = &( lut->border[lb1] );
255 ++lengthLeft;
256 }
257
258
259 if(lb2){
260 phmd->leftBorderP[lengthLeft] = &( lut->border[lb2] );
261 ++lengthLeft;
262 }
263
264 if(rb1){
265 phmd->rightBorderP[lengthRight] = &( lut->border[rb1] );
266 ++lengthRight;
267 }
268
269 if(rb2){
270 phmd->rightBorderP[lengthRight] = &( lut->border[rb2] );
271 ++lengthRight;
272 }
273
274 /* correcting 1st column */
275 for(j=min1; j<=max1; ++j) {
276 phmd->firstColumn[j] = 1;
277 }
278
279 for(j=min2; j<=max2; ++j) {
280 phmd->firstColumn[j] = 1;
281 }
282
283 }
284 ++searchIndex;
285 }
286 /* ------------------------------------------------------------------- */
287
288 }
289 }
290
291 /* ------------------------------------------------------------------- */
292
293 phmd->lengthLeft = lengthLeft;
294 phmd->lengthRight= lengthRight;
295 /* ------------------------------------------- */
296
298
299 /* normal exit */
300 RETURN (status);
301}
int j
#define ABORT(statusptr, code, mesg)
#define ATTATCHSTATUSPTR(statusptr)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
#define fprintf
unsigned char UCHAR
uint64_t UINT8
int16_t INT2
uint32_t UINT4
int32_t INT4
float REAL4
#define PHMDH_MSGESIZE
Definition: PHMD.h:95
#define PHMDH_MSGEVAL
Definition: PHMD.h:100
void LALHOUGHPeak2PHMD(LALStatus *status, HOUGHphmd *phmd, HOUGHptfLUT *lut, HOUGHPeakGram *pg)
Construction of Partial-Hough-Map-Derivatives (phmd) given a peak-gram and the look-up-table.
Definition: Peak2PHMD.c:61
#define PHMDH_MSGEFREQ
Definition: PHMD.h:99
#define PHMDH_EINT
Definition: PHMD.h:89
#define PHMDH_ESIZE
Definition: PHMD.h:87
#define PHMDH_EVAL
Definition: PHMD.h:92
#define PHMDH_MSGENULL
Definition: PHMD.h:94
#define PHMDH_EFREQ
Definition: PHMD.h:91
#define PHMDH_ENULL
Definition: PHMD.h:86
#define PHMDH_MSGEINT
Definition: PHMD.h:97
n
INT2 rightB2
Border index to be used (stop-border ‘ ’)
Definition: LUT.h:238
INT2 leftB1
Border index to be used (start-border ‘ ’)
Definition: LUT.h:235
INT2 piece1min
If piece1min piece1max no corrections should be added.
Definition: LUT.h:240
INT2 piece2max
Interval limits of the (second piece) correction to the first column.
Definition: LUT.h:241
INT2 rightB1
Border index to be used (stop-border ‘ ’)
Definition: LUT.h:236
INT2 piece1max
Interval limits of the (first piece) correction to the first column.
Definition: LUT.h:239
INT2 leftB2
Border index to be used (start-border ‘ ’)
Definition: LUT.h:237
INT2 piece2min
If piece2min piece2max no corrections should be added.
Definition: LUT.h:242
This structure stores the `‘peak-gram’'.
Definition: PHMD.h:129
REAL8 deltaF
Frequency resolution: df=1/TCOH
Definition: PHMD.h:131
UINT4 length
Number of peaks present in the peak-gram.
Definition: PHMD.h:134
UINT8 fBinFin
Frequency index of the last element of the spectrum covered by this peak-gram.
Definition: PHMD.h:133
UINT8 fBinIni
Frequency index of the first element of the spectrum covered by this peak-gram; it can be seen as an ...
Definition: PHMD.h:132
INT4 * peak
The peak indices relative to fBinIni, i.e., the zero peak corresponds to fBinIni.
Definition: PHMD.h:135
This structure stores a partial Hough map derivative.
Definition: PHMD.h:141
UINT2 lengthRight
Exact number of Right borders.
Definition: PHMD.h:144
UINT2 lengthLeft
Exact number of Left borders.
Definition: PHMD.h:143
UINT8 fBin
Frequency bin of this partial map derivative.
Definition: PHMD.h:142
UCHAR * firstColumn
Number of elements of firstColumn.
Definition: PHMD.h:151
UINT2 ySide
number of elements of firstColumn
Definition: PHMD.h:150
HOUGHBorder ** rightBorderP
Pointers to borders.
Definition: PHMD.h:149
HOUGHBorder ** leftBorderP
Pointers to borders.
Definition: PHMD.h:148
This structure stores the patch-time-frequency look up table.
Definition: LUT.h:246
INT4 offset
Frequency bin corresponding to center of patch measured with respect to f0Bin (zero in modulated case...
Definition: LUT.h:255
REAL8 deltaF
Frequency resolution df=1/TCOH, where 1/TCOH is the coherent integration time used in teh demodulatio...
Definition: LUT.h:249
INT4 nBin
Exact number of bins affecting the patch.
Definition: LUT.h:254
HOUGHBorder * border
The annulus borders.
Definition: LUT.h:258
INT4 iniBin
First bin affecting the patch with respect to f0.
Definition: LUT.h:253
HOUGHBin2Border * bin
Bin to border correspondence.
Definition: LUT.h:259
INT8 f0Bin
Frequency bin for which it has been constructed.
Definition: LUT.h:248
INT8 nFreqValid
Number of frequencies where the lut is valid.
Definition: LUT.h:252