LALPulsar  6.1.0.1-b72065a
SFTClean.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005 Badri Krishnan, Alicia Sintes, Greg Mendell
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 _SFTCLEAN_H
20 #define _SFTCLEAN_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /**
27  * \defgroup SFTClean_h Header SFTClean.h
28  * \ingroup lalpulsar_sft
29  * \author Badri Krishnan, Alicia Sintes, Greg Mendell
30  *
31  * \brief Header file for cleaning routines
32  *
33  * Routines for cleaning SFT files using known spectral disturbances.
34  *
35  * ### Synopsis ###
36  *
37  * \code
38  * #include <lal/SFTClean.h>
39  * \endcode
40  *
41  * Format for list of known spectral disturbances and using
42  * them to clean SFT data
43  *
44  * ### Error conditions ###
45  *
46  * Test program. %%
47  *
48  */
49 /** @{ */
50 
51 /* REVISIONS: */
52 /* 09/09/05 gam; make RandomParams *randPar a parameter for CleanCOMPLEX8SFT. Thus only need to */
53 /* initialze RandomParams *randPar once and avoid repeatly opening /dev/urandom. */
54 
55 
56 /*
57  * 5. Includes. This header may include others; if so, they go immediately
58  * after include-loop protection. Includes should appear in the following
59  * order:
60  * a. Standard library includes
61  * b. LDAS includes
62  * c. LAL includes
63  */
64 
65 #include <stdlib.h>
66 #include <math.h>
67 #include <stdio.h>
68 #include <stdlib.h>
69 #include <string.h>
70 #include <lal/LALStdlib.h>
71 #include <lal/LALConstants.h>
72 #include <lal/AVFactories.h>
73 #include <lal/SeqFactories.h>
74 #include <lal/SFTfileIO.h>
75 #include <lal/Random.h>
76 #include <lal/PulsarDataTypes.h>
77 #include <lal/UserInput.h>
78 #include <lal/LUT.h>
79 #include <lal/RngMedBias.h>
80 
81 #include <gsl/gsl_statistics.h>
82 #include <gsl/gsl_rng.h>
83 #include <gsl/gsl_randist.h>
84 #include <gsl/gsl_sort.h>
85 
86 /*
87  * 7. Error codes and messages. This must be auto-extracted for
88  * inclusion in the documentation.
89  */
90 
91 /**\name Error Codes */
92 /** @{ */
93 #define SFTCLEANH_ENULL 1
94 #define SFTCLEANH_EFILE 2
95 #define SFTCLEANH_EHEADER 3
96 #define SFTCLEANH_EENDIAN 4
97 #define SFTCLEANH_EVAL 5
98 #define SFTCLEANH_ELINENAME 6
99 #define SFTCLEANH_ESEEK 9
100 #define SFTCLEANH_EREAD 10
101 #define SFTCLEANH_EWRITE 11
102 
103 #define SFTCLEANH_MSGENULL "Null pointer"
104 #define SFTCLEANH_MSGEFILE "Could not open file"
105 #define SFTCLEANH_MSGEHEADER "Incorrect header in file"
106 #define SFTCLEANH_MSGEENDIAN "Incorrect endian type"
107 #define SFTCLEANH_MSGEVAL "Invalid value"
108 #define SFTCLEANH_MSGELINENAME "Invalid linefile name"
109 #define SFTCLEANH_MSGESEEK "fseek failed"
110 #define SFTCLEANH_MSGEREAD "fread failed"
111 #define SFTCLEANH_MSGEWRITE "fwrite failed"
112 /** @} */
113 
114 
115 /* ******************************************************
116  * 8. Macros. But, note that macros are deprecated.
117  * They could be moved to the modules where are needed
118  */
119 
120 /* *******************************************************
121  * 9. Constant Declarations. (discouraged)
122  */
123 
124 
125 
126 /* **************************************************************
127  * 10. Structure, enum, union, etc., typdefs.
128  */
129 
130 
131 /** structure for storing list of spectral lines -- constructed by expanding list of harmonics*/
132 typedef struct tagLineNoiseInfo {
133  INT4 nLines; /**< number of lines */
134  REAL8 *lineFreq; /**< central frequency of the line in Hz */
135  REAL8 *leftWing; /**< width to the left from central frequency in Hz */
136  REAL8 *rightWing; /**< width to the right in Hz */
137 } LineNoiseInfo;
138 
139 /**
140  * structure for storing the contents of the input list of known
141  * spectral disturbances
142  */
143 typedef struct tagLineHarmonicsInfo {
144  INT4 nHarmonicSets; /**< number of sets of harmonics */
145  REAL8 *startFreq; /**< starting frequency of set in Hz */
146  REAL8 *gapFreq; /**< frequency difference between adjacent harmonics in Hz */
147  INT4 *numHarmonics; /**< Number of harmonics */
148  REAL8 *leftWing; /**< width to the left of each line in set in Hz */
149  REAL8 *rightWing; /**< width to the right in Hz */
151 
152 /*
153  * 11. Extern Global variables. (discouraged)
154  */
155 
156 
157 /*
158  * 12. Functions Declarations (i.e., prototypes).
159  */
160 
161 
163  LineHarmonicsInfo *harmonicInfo,
164  CHAR *fname
165  );
166 
168  LineHarmonicsInfo *lineInfo,
169  CHAR *fname
170  );
171 
173  LineNoiseInfo *lineInfo,
174  LineHarmonicsInfo *harmonicsInfo
175  );
176 
178  LineNoiseInfo *outLine,
179  LineNoiseInfo *inLine,
180  REAL8 freqMin,
181  REAL8 freqMax
182  );
183 
184 
186  INT4 *flag,
187  LineNoiseInfo *lines,
188  REAL8 freq );
189 
190 
192  LineNoiseInfo *lineInfo,
193  CHAR *fname
194  );
195 
197  LineNoiseInfo *lineInfo,
198  CHAR *fname
199  );
200 
202  SFTtype *sft,
203  INT4 width,
204  INT4 window,
205  LineNoiseInfo *lineInfo,
206  RandomParams *randPar );
207 
208 
210  SFTVector *sftVect,
211  INT4 width,
212  INT4 window,
213  LineNoiseInfo *lineInfo,
214  RandomParams *randPar );
215 
217  MultiSFTVector *multVect,
218  INT4 width,
219  INT4 window,
220  LineNoiseInfo *lineInfo,
221  RandomParams *randPar );
222 
224  SFTVector *sftVect,
225  INT4 width,
226  INT4 window,
227  CHAR *linefile,
228  RandomParams *randPar );
229 
231  MultiSFTVector *multiSFTVect,
232  INT4 width,
233  INT4 window,
234  LALStringVector *linefiles,
235  RandomParams *randPar );
236 
237 
238 /** @} */
239 
240 #ifdef __cplusplus
241 } /* Close C++ protection */
242 #endif
243 
244 #endif /* Close double-include protection _SFTCLEAN_H */
double REAL8
char CHAR
int32_t INT4
void LALCleanMultiSFTVect(LALStatus *status, MultiSFTVector *multVect, INT4 width, INT4 window, LineNoiseInfo *lineInfo, RandomParams *randPar)
Function to clean a sft vector – calls LALCleanCOMPLEX8SFT repeatedly for each sft in vector.
Definition: lib/SFTclean.c:814
void LALFindNumberLines(LALStatus *status, LineNoiseInfo *lineInfo, CHAR *fname)
Finds total number of spectral-lines contained in case the input file is a list of explicit spectral ...
Definition: lib/SFTclean.c:282
void LALRemoveKnownLinesInSFTVect(LALStatus *status, SFTVector *sftVect, INT4 width, INT4 window, CHAR *linefile, RandomParams *randPar)
function to remove lines from a sft vector given a file containing list of lines
Definition: lib/SFTclean.c:853
void LALRemoveKnownLinesInMultiSFTVector(LALStatus *status, MultiSFTVector *multiSFTVect, INT4 width, INT4 window, LALStringVector *linefiles, RandomParams *randPar)
top level function to remove lines from a multi sft vector given a list of files containing list of k...
Definition: lib/SFTclean.c:953
void LALCleanSFTVector(LALStatus *status, SFTVector *sftVect, INT4 width, INT4 window, LineNoiseInfo *lineInfo, RandomParams *randPar)
Function to clean a sft vector – calls LALCleanCOMPLEX8SFT repeatedly for each sft in vector.
Definition: lib/SFTclean.c:775
void LALChooseLines(LALStatus *status, LineNoiseInfo *outLine, LineNoiseInfo *inLine, REAL8 freqMin, REAL8 freqMax)
Takes a set of spectral lines and a frequency range as input and returns those lines which lie within...
Definition: lib/SFTclean.c:386
void LALReadLineInfo(LALStatus *status, LineNoiseInfo *lineInfo, CHAR *fname)
Reads information from file containing list of explicit lines - obsolete.
Definition: lib/SFTclean.c:329
void LALCheckLines(LALStatus *status, INT4 *flag, LineNoiseInfo *lines, REAL8 freq)
Function to count how many lines affect a given frequency.
Definition: lib/SFTclean.c:464
void LALFindNumberHarmonics(LALStatus *status, LineHarmonicsInfo *harmonicInfo, CHAR *fname)
Looks into the input file containing list of lines, does some checks on the file format,...
Definition: lib/SFTclean.c:92
void LALReadHarmonicsInfo(LALStatus *status, LineHarmonicsInfo *lineInfo, CHAR *fname)
Reads in the contents of the input line-info file and fills up the LineHarmonicsInfo structure.
Definition: lib/SFTclean.c:149
void LALHarmonics2Lines(LALStatus *status, LineNoiseInfo *lineInfo, LineHarmonicsInfo *harmonicsInfo)
Converts the list of harmonic sets into an explicit list of spectral lines.
Definition: lib/SFTclean.c:210
void LALCleanCOMPLEX8SFT(LALStatus *status, SFTtype *sft, INT4 width, INT4 window, LineNoiseInfo *lineInfo, RandomParams *randPar)
Function for cleaning a SFT given a set of known spectral disturbances.
Definition: lib/SFTclean.c:582
A vector of COMPLEX8FrequencySeries.
structure for storing the contents of the input list of known spectral disturbances
Definition: SFTClean.h:143
REAL8 * gapFreq
frequency difference between adjacent harmonics in Hz
Definition: SFTClean.h:146
REAL8 * rightWing
width to the right in Hz
Definition: SFTClean.h:149
INT4 nHarmonicSets
number of sets of harmonics
Definition: SFTClean.h:144
REAL8 * leftWing
width to the left of each line in set in Hz
Definition: SFTClean.h:148
INT4 * numHarmonics
Number of harmonics.
Definition: SFTClean.h:147
REAL8 * startFreq
starting frequency of set in Hz
Definition: SFTClean.h:145
structure for storing list of spectral lines – constructed by expanding list of harmonics
Definition: SFTClean.h:132
REAL8 * lineFreq
central frequency of the line in Hz
Definition: SFTClean.h:134
REAL8 * leftWing
width to the left from central frequency in Hz
Definition: SFTClean.h:135
REAL8 * rightWing
width to the right in Hz
Definition: SFTClean.h:136
INT4 nLines
number of lines
Definition: SFTClean.h:133
A collection of SFT vectors – one for each IFO in a multi-IFO search.
Definition: SFTfileIO.h:179