LALPulsar  6.1.0.1-fe68b98
PHMD.h
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 #ifndef _PHMD_H
20 #define _PHMD_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /**
27  * \defgroup PHMD_h Header PHMD.h
28  * \ingroup lalpulsar_hough
29  * \author Sintes, A. M.
30  * \date 2001
31  * \brief Conversion from peaks in a spectrum into a partial Hough map derivative
32  *
33  * ### Synopsis ###
34  *
35  * \code
36  * #include <lal/PHMD.h>
37  * \endcode
38  *
39  * The Hough map is an histogram, thus additive. It can be seen as the sum of several
40  * partial Hough maps constructed using just one periodogram, or equivalently, as
41  * the sum of partial Hough map derivatives (\c phmd) and then integrating the
42  * result.
43  *
44  * A \c phmd can be represented by a set of borders, here called <em>left</em> and \e right.
45  * They indicate the beginning and the end of the annuli.
46  * The position of the so-called left borders should be marked with \f$ +1 \f$ , and
47  * the position of the right borders should be marked with \f$ -1 \f$ in the \c phmd.
48  * To obtain a partial Hough map, one needs to integrate each row of the \c phmd
49  * from left to right.
50  *
51  * The representation of a \c phmd is simplified by considering
52  * pointers to the borders in a pre-calculated look-up-table, plus some extra information about
53  * their character and edge effects when clipping on a finite patch.
54  *
55  */
56 /** @{ */
57 
58 /*
59  * 5. Includes. This header may include others; if so, they go immediately
60  * after include-loop protection. Includes should appear in the following
61  * order:
62  * a. Standard library includes
63  * b. LDAS includes
64  * c. LAL includes
65  */
66 
67 #include <stdlib.h>
68 #include <math.h>
69 #include <stdio.h>
70 # include <stdlib.h>
71 # include <string.h>
72 #include <lal/LALStdlib.h>
73 #include <lal/LALConstants.h>
74 #include <lal/AVFactories.h>
75 #include <lal/SeqFactories.h>
76 
77 #include <lal/LUT.h>
78 
79 /*
80  * 7. Error codes and messages. This must be auto-extracted for
81  * inclusion in the documentation.
82  */
83 
84 /**\name Error Codes */
85 /** @{ */
86 #define PHMDH_ENULL 1
87 #define PHMDH_ESIZE 2
88 #define PHMDH_ESZMM 4
89 #define PHMDH_EINT 6
90 #define PHMDH_ESAME 8
91 #define PHMDH_EFREQ 10
92 #define PHMDH_EVAL 12
93 
94 #define PHMDH_MSGENULL "Null pointer"
95 #define PHMDH_MSGESIZE "Invalid input size"
96 #define PHMDH_MSGESZMM "Size mismatch"
97 #define PHMDH_MSGEINT "Invalid interval"
98 #define PHMDH_MSGESAME "Input/Output data vectors are the same"
99 #define PHMDH_MSGEFREQ "Invalid frequency"
100 #define PHMDH_MSGEVAL "Invalid value"
101 /** @} */
102 
103 
104 /* ******************************************************
105  * 8. Macros. But, note that macros are deprecated.
106  * They could be moved to the modules where are needed
107  */
108 
109 
110 /* *******************************************************
111  * 9. Constant Declarations. (discouraged)
112  */
113 
114 
115 
116 /* **************************************************************
117  * 10. Structure, enum, union, etc., typdefs.
118  */
119 
120 /** Hough Map derivative pixel type */
121 typedef REAL8 HoughDT; /* for weighted hough maps */
122 /* typedef CHAR HoughDT; */
123 /* typedef INT2 HoughDT; */
124 
125 
126 /**
127  * \brief This structure stores the ``peak-gram''
128  */
129  typedef struct tagHOUGHPeakGram{
130  INT2 timeIndex; /**< The time index of the peak-gram */
131  REAL8 deltaF; /**< Frequency resolution: <tt>df=1/TCOH</tt> */
132  UINT8 fBinIni; /**< Frequency index of the first element of the spectrum covered by this peak-gram; it can be seen as an offset */
133  UINT8 fBinFin; /**< Frequency index of the last element of the spectrum covered by this peak-gram */
134  UINT4 length; /**< Number of peaks present in the peak-gram */
135  INT4 *peak; /**< The peak indices relative to \c fBinIni, i.e., the zero peak corresponds to \c fBinIni */
136  } HOUGHPeakGram;
137 
138 /**
139  * \brief This structure stores a partial Hough map derivative
140  */
141 typedef struct tagHOUGHphmd{
142  UINT8 fBin; /**< Frequency bin of this partial map derivative */
143  UINT2 lengthLeft; /**< Exact number of \e Left borders */
144  UINT2 lengthRight; /**< Exact number of \e Right borders */
145  UINT2 maxNBorders; /**< Maximun number of borders of each type (for memory allocation purposes),
146  * i.e.\ length of <tt>*leftBorderP</tt> and <tt>*rightBorderP</tt>
147  */
148  HOUGHBorder **leftBorderP; /**< Pointers to borders */
149  HOUGHBorder **rightBorderP;/**< Pointers to borders */
150  UINT2 ySide; /**< number of elements of firstColumn */
151  UCHAR *firstColumn; /**< Number of elements of \c firstColumn */
152  HoughDT weight; /**< First column border, containing the edge effects when clipping on a finite patch */
153 } HOUGHphmd;
154 
155 /*
156  * 11. Extern Global variables. (discouraged)
157  */
158 
159 /*
160  * 12. Functions Declarations (i.e., prototypes).
161  */
162 
164  HOUGHphmd *phmd,
165  HOUGHptfLUT *lut,
166  HOUGHPeakGram *pg
167  );
168 
169 /** @} */
170 #ifdef __cplusplus
171 } /* Close C++ protection */
172 #endif
173 
174 #endif /* Close double-include protection _PHMD_H */
unsigned char UCHAR
uint64_t UINT8
double REAL8
int16_t INT2
uint16_t UINT2
uint32_t UINT4
int32_t INT4
REAL8 HoughDT
Hough Map derivative pixel type.
Definition: PHMD.h:121
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
This structure stores the border of a circle clipped on the projected plane.
Definition: LUT.h:221
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
INT2 timeIndex
The time index of the peak-gram.
Definition: PHMD.h:130
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
HoughDT weight
First column border, containing the edge effects when clipping on a finite patch.
Definition: PHMD.h:152
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
UINT2 maxNBorders
Maximun number of borders of each type (for memory allocation purposes), i.e. length of *leftBorderP ...
Definition: PHMD.h:145
HOUGHBorder ** leftBorderP
Pointers to borders.
Definition: PHMD.h:148
This structure stores the patch-time-frequency look up table.
Definition: LUT.h:246