LALPulsar  6.1.0.1-89842e6
PulsarCrossCorr.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2007 Badri Krishnan
3  * Copyright (C) 2008 Christine Chung, Badri Krishnan and John Whelan
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with with program; see the file COPYING. If not, write to the
17  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
18  * MA 02110-1301 USA
19  */
20 #ifndef _PULSARCROSSCORR_H
21 #define _PULSARCROSSCORR_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /**
28  * \defgroup PulsarCrossCorr_h Header PulsarCrossCorr.h
29  * \ingroup lalpulsar_crosscorr
30  * \author Christine Chung, Badri Krishnan, John Whelan
31  * \date 2008
32  * \brief Header-file for LAL routines for CW cross-correlation searches
33  *
34  */
35 /** @{ */
36 
37 #include <sys/types.h>
38 #include <sys/stat.h>
39 #include <fcntl.h>
40 #include <string.h>
41 #include <stdio.h>
42 #include <stdlib.h>
43 #include <math.h>
44 #if HAVE_GLOB_H
45 #include <glob.h>
46 #endif
47 #include <time.h>
48 #include <errno.h>
49 
50 #include <lal/AVFactories.h>
51 #include <lal/Date.h>
52 #include <lal/DetectorSite.h>
53 #include <lal/LALDatatypes.h>
54 #include <lal/LALHough.h>
55 #include <lal/RngMedBias.h>
56 #include <lal/LALRunningMedian.h>
57 #include <lal/Velocity.h>
58 #include <lal/Statistics.h>
59 #include <lal/ComputeFstat.h>
60 #include <lal/SFTfileIO.h>
61 #include <lal/NormalizeSFTRngMed.h>
62 #include <lal/LALInitBarycenter.h>
63 #include <lal/SFTClean.h>
64 #include <gsl/gsl_cdf.h>
65 #include <lal/FrequencySeries.h>
66 #include <lal/Sequence.h>
67 
68 /** \name Error codes */
69 /** @{ */
70 #define PULSARCROSSCORR_ENULL 1
71 #define PULSARCROSSCORR_ENONULL 2
72 #define PULSARCROSSCORR_EVAL 3
73 
74 #define PULSARCROSSCORR_MSGENULL "Null pointer"
75 #define PULSARCROSSCORR_MSGENONULL "Non-null pointer"
76 #define PULSARCROSSCORR_MSGEVAL "Invalid value"
77 /** @} */
78 
79 /* ******************************************************************
80  * Structure, enum, union, etc., typdefs.
81  */
82 
83 typedef enum tagDetChoice {
86  ALL
88 
89 
90 /** struct holding info about skypoints */
91 typedef struct tagSkyPatchesInfo {
98 
99 typedef struct tagSFTDetectorInfo {
101  REAL8 vDetector[3];
102  REAL8 rDetector[3];
106 
107 /* define structs to hold combinations of F's and A's */
108 typedef struct tagCrossCorrAmps {
112 } CrossCorrAmps;
113 
114 typedef struct tagCrossCorrBeamFn {
118 
119 typedef struct tagSFTListElement {
121  struct tagSFTListElement *nextSFT;
123 
124 typedef struct tagPSDListElement {
126  struct tagPSDListElement *nextPSD;
128 
129 typedef struct tagREAL8ListElement {
131  struct tagREAL8ListElement *nextVal;
133 
134 typedef struct tagCrossCorrBeamFnListElement {
136  struct tagCrossCorrBeamFnListElement *nextBeamfn;
138 /*
139  * Functions Declarations (i.e., prototypes).
140  */
141 
143  INT4VectorSequence **out,
144  SFTListElement *in,
145  REAL8 lag,
146  INT4 listLength,
147  DetChoice detChoice,
148  BOOLEAN autoCorrelate );
149 
151  COMPLEX16 *out,
154  REAL8FrequencySeries *psd1,
155  REAL8FrequencySeries *psd2,
156  UINT4 bin1,
157  UINT4 bin2 );
158 
160  REAL8 *out,
161  LIGOTimeGPS *epoch,
162  PulsarDopplerParams *dopp,
163  REAL8Vector *vel );
164 
166  REAL8 *out,
167  LIGOTimeGPS *epoch,
168  PulsarDopplerParams *dopp,
169  REAL8Vector *pos );
170 
172  REAL8 *out,
173  UINT4 bin1,
174  UINT4 bin2,
175  REAL8FrequencySeries *psd1,
176  REAL8FrequencySeries *psd2 );
177 
179  COMPLEX16 *out,
180  REAL8 phiI,
181  REAL8 phiJ,
182  REAL8 freqI,
183  REAL8 freqJ,
184  REAL8 deltaF,
185  CrossCorrBeamFn beamfnsI,
186  CrossCorrBeamFn beamfnsJ,
187  REAL8 sigmasq );
188 
190  COMPLEX16 *out,
191  CrossCorrAmps amplitudes,
192  REAL8 phiI,
193  REAL8 phiJ,
194  REAL8 freqI,
195  REAL8 freqJ,
196  REAL8 deltaF,
197  CrossCorrBeamFn beamfnsI,
198  CrossCorrBeamFn beamfnsJ,
199  REAL8 sigmasq,
200  REAL8 *psi,
201  COMPLEX16 *gplus,
202  COMPLEX16 *gcross );
203 
205  REAL8 *out,
206  COMPLEX16Vector *yalpha,
207  COMPLEX16Vector *ualpha );
208 
210  REAL8 *out,
211  COMPLEX16Vector *ualpha,
212  REAL8Vector *sigmaAlphasq );
213 
215  REAL8 *aplussq1,
216  REAL8 *aplussq2,
217  REAL8 *acrossq1,
218  REAL8 *acrossq2,
219  COMPLEX16Vector *yalpha,
220  COMPLEX16Vector *gplus,
221  COMPLEX16Vector *gcross,
222  REAL8Vector *sigmaAlphasq );
223 
224 /** @} */
225 
226 #ifdef __cplusplus
227 } /* Close C++ protection */
228 #endif
229 
230 
231 #endif /* Close double-include protection _PULSARCROSSCORR_H */
unsigned char BOOLEAN
double complex COMPLEX16
double REAL8
uint32_t UINT4
int32_t INT4
void LALCalculateEstimators(LALStatus *status, REAL8 *aplussq1, REAL8 *aplussq2, REAL8 *acrossq1, REAL8 *acrossq2, COMPLEX16Vector *yalpha, COMPLEX16Vector *gplus, COMPLEX16Vector *gcross, REAL8Vector *sigmaAlphasq)
void LALCalculateAveUalpha(LALStatus *status, COMPLEX16 *out, REAL8 phiI, REAL8 phiJ, REAL8 freqI, REAL8 freqJ, REAL8 deltaF, CrossCorrBeamFn beamfnsI, CrossCorrBeamFn beamfnsJ, REAL8 sigmasq)
Calculate pair weights (U_alpha) for an average over Psi and cos(iota)
void LALCreateSFTPairsIndicesFrom2SFTvectors(LALStatus *status, INT4VectorSequence **out, SFTListElement *in, REAL8 lag, INT4 listLength, DetChoice detChoice, BOOLEAN autoCorrelate)
void LALCalculateSigmaAlphaSq(LALStatus *status, REAL8 *out, UINT4 bin1, UINT4 bin2, REAL8FrequencySeries *psd1, REAL8FrequencySeries *psd2)
void LALGetSignalFrequencyInSFT(LALStatus *status, REAL8 *out, LIGOTimeGPS *epoch, PulsarDopplerParams *dopp, REAL8Vector *vel)
Calculate the frequency of the SFT at a given epoch.
void LALCorrelateSingleSFTPair(LALStatus *status, COMPLEX16 *out, COMPLEX8FrequencySeries *sft1, COMPLEX8FrequencySeries *sft2, REAL8FrequencySeries *psd1, REAL8FrequencySeries *psd2, UINT4 bin1, UINT4 bin2)
Correlate a single pair of SFT at a parameter space point.
void LALCalculateUalpha(LALStatus *status, COMPLEX16 *out, CrossCorrAmps amplitudes, REAL8 phiI, REAL8 phiJ, REAL8 freqI, REAL8 freqJ, REAL8 deltaF, CrossCorrBeamFn beamfnsI, CrossCorrBeamFn beamfnsJ, REAL8 sigmasq, REAL8 *psi, COMPLEX16 *gplus, COMPLEX16 *gcross)
Calculate pair weights (U_alpha) for the general case.
void LALGetSignalPhaseInSFT(LALStatus *status, REAL8 *out, LIGOTimeGPS *epoch, PulsarDopplerParams *dopp, REAL8Vector *pos)
Get signal phase at a given epoch.
void LALCalculateCrossCorrPower(LALStatus *status, REAL8 *out, COMPLEX16Vector *yalpha, COMPLEX16Vector *ualpha)
void LALNormaliseCrossCorrPower(LALStatus *status, REAL8 *out, COMPLEX16Vector *ualpha, REAL8Vector *sigmaAlphasq)
DetChoice
@ SAME
@ ALL
@ DIFFERENT
struct tagCrossCorrBeamFnListElement * nextBeamfn
REAL8FrequencySeries psd
struct tagPSDListElement * nextPSD
Type containing the 'Doppler-parameters' affecting the time-evolution of the phase.
struct tagREAL8ListElement * nextVal
COMPLEX8FrequencySeries * sft
struct tagSFTListElement * nextSFT
struct holding info about skypoints