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
pulsar_crosscorr_v2.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2013 Badri Krishnan, Shane Larson, John Whelan
3 * Copyright (C) 2013, 2014 Badri Krishnan, John Whelan, Yuanhao Zhang
4 * Copyright (C) 2016, 2017 Grant David Meadors
5 * Copyright (C) 2020, 2021 Jared Wofford, John Whelan
6 * Copyright (C) 2023 John Whelan
7 * Copyright (C) 2024 Binod Rajbhandari, John Whelan
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with with program; see the file COPYING. If not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 * MA 02110-1301 USA
23 */
24
25#include "config.h"
26
27#include <lal/UserInput.h>
28#include <lal/SFTfileIO.h>
29#include <lal/LogPrintf.h>
30#include <lal/DopplerScan.h>
31#include <lal/DetectorStates.h>
32#include <lal/ExtrapolatePulsarSpins.h>
33#include <lal/LALInitBarycenter.h>
34#include <lal/NormalizeSFTRngMed.h>
35#include <lal/LALString.h>
36#include <lal/PulsarCrossCorr_v2.h>
37#include <lal/LALPulsarVCSInfo.h>
38
39#include "CrossCorrToplist.h"
40#include <lal/LatticeTiling.h>
41#include <lal/TascPorbTiling.h>
42
43
44/**
45 * \author B.Krishnan, S.Larson, J.T.Whelan, Y.Zhang, G.D.Meadors, J.K.Wofford
46 * \date 2013, 2014, 2015, 2016, 2017, 2020, 2021
47 * \file
48 * \ingroup lalpulsar_bin_CrossCorr
49 * \brief Perform CW cross-correlation search - version 2
50 *
51 * This carries out the cross-correlation search defined in
52 * \cite Dhurandhar2007, and specifically the implementation detailed
53 * in \cite Whelan2015 . The SFT-normalization routines described in
54 * \cite T0900149-v5 are leveraged.
55 */
56/** @{ */
57
58/* introduce mismatch in f and all 5 binary parameters */
59
60/* user input variables */
61typedef struct tagUserInput_t {
62 INT4 startTime; /**< desired start GPS time of search */
63 INT4 endTime; /**< desired end GPS time */
64 REAL8 maxLag; /**< maximum lag time in seconds between SFTs in correlation */
65 BOOLEAN inclAutoCorr; /**< include auto-correlation terms (an SFT with itself) */
66 REAL8 fStart; /**< start frequency in Hz */
67 REAL8 fBand; /**< frequency band to search over in Hz */
68 /* REAL8 fdotStart; /\**< starting value for first spindown in Hz/s*\/ */
69 /* REAL8 fdotBand; /\**< range of first spindown to search over in Hz/s *\/ */
70 REAL8 alphaRad; /**< right ascension in radians */
71 REAL8 deltaRad; /**< declination in radians */
72 REAL8 refTime; /**< reference time for pulsar phase definition */
73 REAL8 orbitAsiniSec; /**< start projected semimajor axis in seconds */
74 REAL8 orbitAsiniSecBand; /**< band for projected semimajor axis in seconds */
75 REAL8 orbitPSec; /**< binary orbital period in seconds */
76 REAL8 orbitPSecBand; /**< band for binary orbital period in seconds*/
77 REAL8 orbitTimeAsc; /**< start time of ascension for binary orbit */
78 REAL8 orbitTimeAscBand; /**< band for time of ascension for binary orbit */
79 CHAR *sftLocation; /**< location of SFT data */
80 CHAR *ephemEarth; /**< Earth ephemeris file to use */
81 CHAR *ephemSun; /**< Sun ephemeris file to use */
82 INT4 rngMedBlock; /**< running median block size */
83 INT4 numBins; /**< number of frequency bins to include in sum */
84 REAL8 mismatchF; /**< mismatch for frequency spacing */
85 REAL8 mismatchA; /**< mismatch for spacing in semi-major axis */
86 REAL8 mismatchT; /**< mismatch for spacing in time of periapse passage */
87 REAL8 mismatchP; /**< mismatch for spacing in period */
88 REAL8 spacingF; /**< spacing in frequency */
89 REAL8 spacingA; /**< spacing in semi-major axis*/
90 REAL8 spacingT; /**< spacing in time of periapse passage*/
91 REAL8 spacingP; /**< spacing in period*/
92 INT4 numCand; /**< number of candidates to keep in output toplist */
93 CHAR *linesToCleanFilenames; /**< comma-separated list of filenames with known lines for each ifo */
94 CHAR *pairListInputFilename; /**< input filename containing list of sft index pairs (if not provided, determine list of pairs) */
95 CHAR *pairListOutputFilename; /**< output filename to write list of sft index pairs */
96 CHAR *resampPairListOutputFilename; /**< output filename to write list of Tshort index pairs */
97 CHAR *sftListOutputFilename; /**< output filename to write list of sfts */
98 CHAR *tShortListOutputFilename; /**< output filename to write list of Tshorts */
99 CHAR *sftListInputFilename; /**< input filename to read in the list of sfts and check the order of SFTs */
100 CHAR *gammaAveOutputFilename; /**< output filename to write Gamma_ave = (aa+bb)/10 */
101 CHAR *resampGammaAveOutputFilename; /**< output filename to write Gamma_ave = (aa+bb)/10 for Tshort pairs */
102 CHAR *gammaCircOutputFilename; /**< output filename to write Gamma_circ = (ab-ba)/10 */
103 CHAR *resampGammaCircOutputFilename; /**< output filename to write Gamma_circ = (ab-ba)/10 for Tshort pairs */
104 CHAR *toplistFilename; /**< output filename containing candidates in toplist */
105 CHAR *logFilename; /**< name of log file*/
106 BOOLEAN resamp; /**< use resampling */
107 REAL8 tShort; /**< resampling tShort for time series subdivisions pre-FFT */
108 BOOLEAN testShortFunctions; /**< alternative pathway with tShort using resampMultiPairs and new functions */
109 BOOLEAN testResampNoTShort; /**< use resampling without tShort (for e.g., comparison in gapless Gaussian data) */
110 BOOLEAN alignTShorts; /**< make sure tShort segments from different detectors are aligned */
111 BOOLEAN accurateResampMetric; /**< Use more accurate calculation of metric for resampling */
112 INT4 Dterms; /**< number of Dirichlet terms to use for resampling sinc interpolation */
113 REAL8 allowedMismatchFromSFTLength; /**< mismatch to tolerate in XLALFstatCheckSFTLengthMismatch() */
114 BOOLEAN inclSameDetector; /**< include cross-correlations of detector with itself */
115 BOOLEAN treatWarningsAsErrors; /**< treat any warnings as errors and abort */
116 LALStringVector *injectionSources; /**< CSV file list containing sources to inject or '{Alpha=0;Delta=0;...}' */
117
118 BOOLEAN useLattice; /**< use latticeTiling for template placement */
119 BOOLEAN useShearedPorb; /**< use sheared orbital period */
120 REAL8 unresolvedPorbMismatch; /**< use only one point in period direction if maximum mismatch in that direction is below this */
121 BOOLEAN reallocatePorbMismatch; /**< subtract actual period mismatch from other directions rather than maximum */
122 INT4 latticeType; /**< lattice to use */
123 REAL8 mismatchMax; /**< total mismatch */
124
125 /*elliptical boundary */
126 REAL8 orbitPSecCenter; /**< Center of prior ellipse for binary orbital period (seconds) */
127 REAL8 orbitPSecSigma; /**< One-sigma uncertainty of prior ellipse for binary orbital period (seconds) */
128 REAL8 orbitTimeAscCenter; /**< Center of prior ellipse for binary time of ascension (GPS seconds) */
129 REAL8 orbitTimeAscSigma; /**< One-sigma uncertainty of prior ellipse for binary time of ascension (seconds) */
130 REAL8 orbitTPEllipseRadius; /**< Radius of search ellipse (sigma) */
131
132 CHAR *LatticeOutputFilename; /**< output filename to write list of sft index pairs */
133
135
136/* struct to store useful variables */
137typedef struct tagConfigVariables {
138 SFTCatalog *catalog; /**< catalog of SFTs */
139 EphemerisData *edat; /**< ephemeris data */
140 LALStringVector *lineFiles; /**< list of line files */
141 REAL8 refTime; /**< reference time for pulsar phase definition */
142 REAL8 orbitPSecMin; /**< minimum binary orbital period in seconds */
143 REAL8 orbitPSecMax; /**< maximum binary orbital period in seconds*/
144 BOOLEAN useTPEllipse; /**< whether to use elliptical boundary for Tasc-Porb search space */
145 int norb; /**< number of orbits to shift prior elliptical boundary for Tasc-Porb search space */
146 REAL8 orbitTimeAscCenterShifted; /**< shifted center of prior ellipse for binary time of ascension (GPS seconds) */
147 REAL8 dPorbdTascShear; /**< slope of centerline of prior ellipse */
148 REAL8 unshearedgTT; /**< metric element gTT in unsheared coordinates */
149 REAL8 unshearedgTP; /**< metric element gTP in unsheared coordinates */
150 REAL8 mismatchMaxP; /**< maximum mismatch in porb */
151 REAL8 mismatchMaxThreeD; /**< mismatch used for 3d lattice */
153
154#define TRUE (1==1)
155#define FALSE (1==0)
156#define MAXFILENAMELENGTH 512
157#define MAXLINELENGTH 1024
158// Square of a number
159#define SQR(x) ((x)*(x))
160
161#define MYMAX(x,y) ( (x) > (y) ? (x) : (y) )
162#define MYMIN(x,y) ( (x) < (y) ? (x) : (y) )
163#define USE_ALIGNED_MEMORY_ROUTINES
164
165/* local function prototypes */
166int XLALInitUserVars( UserInput_t *uvar );
167int XLALInitializeConfigVars( ConfigVariables *config, const UserInput_t *uvar );
169int GetNextCrossCorrTemplate( BOOLEAN *binaryParamsFlag, BOOLEAN *firstPoint, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *binaryTemplateSpacings, PulsarDopplerParams *minBinaryTemplate, PulsarDopplerParams *maxBinaryTemplate, UINT8 *fCount, UINT8 *aCount, UINT8 *tCount, UINT8 *pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, ConfigVariables *config );
170/* int GetNextCrossCorrTemplateResamp(BOOLEAN *binaryParamsFlag, BOOLEAN *firstPoint, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *binaryTemplateSpacings, PulsarDopplerParams *minBinaryTemplate, PulsarDopplerParams *maxBinaryTemplate, UINT8 *fCount, UINT8 *aCount, UINT8 *tCount, UINT8 *pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum); */
171int GetNextCrossCorrTemplateForResamp( BOOLEAN *binaryParamsFlag, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *binaryTemplateSpacings, PulsarDopplerParams *minBinaryTemplate, PulsarDopplerParams *maxBinaryTemplate, UINT8 *fCount, UINT8 *aCount, UINT8 *tCount, UINT8 *pCount, ConfigVariables *config );
172int demodLoopCrossCorr( MultiSSBtimes *multiBinaryTimes, MultiSSBtimes *multiSSBTimes, PulsarDopplerParams dopplerpos, BOOLEAN dopplerShiftFlag, PulsarDopplerParams binaryTemplateSpacings, PulsarDopplerParams minBinaryTemplate, PulsarDopplerParams maxBinaryTemplate, UINT8 fCount, UINT8 aCount, UINT8 tCount, UINT8 pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, REAL8Vector *shiftedFreqs, UINT4Vector *lowestBins, COMPLEX8Vector *expSignalPhases, REAL8VectorSequence *sincList, UserInput_t uvar, SFTIndexList *sftIndices, MultiSFTVector *inputSFTs, MultiUINT4Vector *badBins, REAL8 Tsft, MultiNoiseWeights *multiWeights, REAL8 ccStat, REAL8 evSquared, REAL8 estSens, REAL8Vector *GammaAve, SFTPairIndexList *sftPairs, CrossCorrBinaryOutputEntry thisCandidate, toplist_t *ccToplist, int DEMODndim, int DEMODdimf, int DEMODdima, int DEMODdimT, int DEMODdimP, gsl_matrix *metric_ij, int *DEMODnumpoints, int *DEMODnumorb, ConfigVariables *config );
173/* int resampLoopCrossCorr(MultiSSBtimes *multiBinaryTimes, MultiSSBtimes *multiSSBTimes, PulsarDopplerParams dopplerpos, BOOLEAN dopplerShiftFlag, PulsarDopplerParams binaryTemplateSpacings, PulsarDopplerParams minBinaryTemplate, PulsarDopplerParams maxBinaryTemplate, UINT8 fCount, UINT8 aCount, UINT8 tCount, UINT8 pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, REAL8Vector *shiftedFreqs, UINT4Vector *lowestBins, COMPLEX8Vector *expSignalPhases, REAL8VectorSequence *sincList, UserInput_t uvar, SFTIndexList *sftIndices, MultiSFTVector *inputSFTs, MultiUINT4Vector *badBins, REAL8 Tsft, MultiNoiseWeights *multiWeights, REAL8 ccStat, REAL8 evSquared, REAL8 estSens, REAL8Vector *GammaAve, SFTPairIndexList *sftPairs, CrossCorrBinaryOutputEntry thisCandidate, toplist_t *ccToplist ); */
174int resampForLoopCrossCorr( PulsarDopplerParams dopplerpos, BOOLEAN dopplerShiftGlag, PulsarDopplerParams binaryTemplateSpacings, PulsarDopplerParams minBinaryTemplate, PulsarDopplerParams maxBinaryTemplate, UINT8 fCount, UINT8 aCount, UINT8 tCount, UINT8 pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, UserInput_t uvar, MultiNoiseWeights *multiWeights, UINT4 *numSamplesFFT, REAL8Vector *ccStatVector, REAL8Vector *evSquaredVector, REAL8Vector *numeEquivAve, REAL8Vector *numeEquivCirc, REAL8 estSens, REAL8Vector *resampGammaAve, MultiResampSFTPairMultiIndexList *resampMultiPairs, CrossCorrBinaryOutputEntry thisCandidate, toplist_t *ccToplist, REAL8 tShort, ConfigVariables *config );
175int testShortFunctionsBlock( UserInput_t uvar, MultiSFTVector *inputSFTs, REAL8 Tsft, REAL8 resampTshort, SFTIndexList **sftIndices, SFTPairIndexList **sftPairs, REAL8Vector **GammaAve, REAL8Vector **GammaCirc, MultiResampSFTPairMultiIndexList **resampMultiPairs, MultiLALDetector *multiDetectors, MultiDetectorStateSeries **multiStates, MultiDetectorStateSeries **resampMultiStates, MultiNoiseWeights **multiWeights, MultiLIGOTimeGPSVector **multiTimes, MultiLIGOTimeGPSVector **resampMultiTimes, MultiSSBtimes **multiSSBTimes, REAL8VectorSequence **phaseDerivs, gsl_matrix **g_ij, gsl_vector **eps_i, REAL8 estSens, SkyPosition *skypos, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *thisBinaryTemplate, ConfigVariables config, const DopplerCoordinateSystem coordSys );
176UINT4 pcc_count_csv( CHAR *csvline );
177INT4 XLALFindBadBins( UINT4Vector *badBinData, INT4 binCount, REAL8 flo, REAL8 fhi, REAL8 f0, REAL8 deltaF, UINT4 length ) ;
178/** @} */
179
180int main( int argc, char *argv[] )
181{
182
184 static ConfigVariables config;
185
186 /* sft related variables */
187 MultiSFTVector *inputSFTs = NULL;
188 MultiPSDVector *multiPSDs = NULL;
189 MultiNoiseWeights *multiWeights = NULL;
190 MultiNoiseWeights *resampMultiWeights = NULL;
191 MultiLIGOTimeGPSVector *multiTimes = NULL;
192 MultiLIGOTimeGPSVector *resampMultiTimes = NULL;
193 MultiLALDetector multiDetectors;
194 MultiDetectorStateSeries *multiStates = NULL;
195 MultiDetectorStateSeries *resampMultiStates = NULL;
196 MultiAMCoeffs *multiCoeffs = NULL;
197 MultiAMCoeffs *resampMultiCoeffs = NULL;
198 SFTIndexList *sftIndices = NULL;
199 SFTIndexList *tShortIndices = NULL;
200 SFTPairIndexList *sftPairs = NULL;
201 SFTPairIndexList *tShortPairs = NULL;
202 UINT4VectorSequence *sftPairForTshortPair = NULL;
203 MultiResampSFTPairMultiIndexList *resampMultiPairs = NULL;
204 REAL8Vector *shiftedFreqs = NULL;
205 UINT4Vector *lowestBins = NULL;
206 REAL8VectorSequence *sincList = NULL;
208 PulsarDopplerParams thisBinaryTemplate, binaryTemplateSpacings;
209 PulsarDopplerParams minBinaryTemplate, maxBinaryTemplate;
210 SkyPosition XLAL_INIT_DECL( skyPos );
211 MultiSSBtimes *multiBinaryTimes = NULL;
212
213 INT4 k;
214 UINT4 j;
215 REAL8 fMin, fMax; /* min and max frequencies read from SFTs */
216 REAL8 deltaF; /* frequency resolution associated with time baseline of SFTs */
217
218 BOOLEAN dopplerShiftFlag = TRUE;
219 toplist_t *ccToplist = NULL;
221 UINT4 checksum;
222 CHARVector *dimName = NULL;
223
224 LogPrintf( LOG_CRITICAL, "Starting time\n" ); /*for debug convenience to record calculating time*/
225 /* initialize and register user variables */
226 LIGOTimeGPS computingStartGPSTime, computingEndGPSTime;
227 XLALGPSTimeNow( &computingStartGPSTime ); /* record the rough starting GPS time*/
228
229 if ( XLALInitUserVars( &uvar ) != XLAL_SUCCESS ) {
230 LogPrintf( LOG_CRITICAL, "%s: XLALInitUserVars() failed with errno=%d\n", __func__, xlalErrno );
232 }
233
234 /* read user input from the command line or config file */
235 BOOLEAN should_exit = 0;
236 if ( XLALUserVarReadAllInput( &should_exit, argc, argv, lalPulsarVCSInfoList ) != XLAL_SUCCESS ) {
237 LogPrintf( LOG_CRITICAL, "%s: XLALUserVarReadAllInput() failed with errno=%d\n", __func__, xlalErrno );
239 }
240 if ( should_exit ) {
241 return EXIT_FAILURE;
242 }
243
244 CHAR *VCSInfoString = XLALVCSInfoString( lalPulsarVCSInfoList, 0, "%% " ); /**< Git version string*/
245
246 /* configure useful variables based on user input */
247 if ( XLALInitializeConfigVars( &config, &uvar ) != XLAL_SUCCESS ) {
248 LogPrintf( LOG_CRITICAL, "%s: XLALInitUserVars() failed with errno=%d\n", __func__, xlalErrno );
250 }
251
252 deltaF = config.catalog->data[0].header.deltaF;
253 REAL8 Tsft = 1.0 / deltaF;
254 /* Introduce tShort, initializing to maxLag */
255 REAL8 resampTshort = uvar.maxLag;
256 if ( ( uvar.resamp == TRUE ) && XLALUserVarWasSet( &uvar.tShort ) ) {
257 resampTshort = uvar.tShort;
258 printf( "Using tShort: %f\n", resampTshort );
259 }
260 if ( !( uvar.resamp == TRUE ) && XLALUserVarWasSet( &uvar.tShort ) ) {
261 printf( "Warning! Please note that tShort is designed to be used with resampling flag, --resamp TRUE\n" );
262 printf( "Proceeding without resampling...\n" );
263 if ( uvar.treatWarningsAsErrors ) {
264 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
266 }
267 }
268 if ( ( uvar.resamp == TRUE ) && ( uvar.testResampNoTShort == TRUE ) ) {
269 /* set resampling "tShort" back to Tsft for this test case, as
270 * there is no distinct tShort anymore */
271 resampTshort = Tsft;
272 printf( "Caution: test mode with no tShort detected with resampling. Please note,...\n results may be inconsistent when data contains gaps,...\n for which tShort is recommended.\n" );
273 }
274 if ( ( uvar.resamp == FALSE ) && ( uvar.testResampNoTShort == TRUE ) ) {
275 printf( "Warning! testResampNoTShort should only be used with --resamp TRUE\n" );
276 printf( "Proceeding, but unexpected behavior may follow...\n" );
277 if ( uvar.treatWarningsAsErrors ) {
278 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
280 }
281 }
282 if ( !( ( uvar.resamp == TRUE ) && ( uvar.testResampNoTShort == FALSE ) ) && ( uvar.testShortFunctions == TRUE ) ) {
283 printf( "Warning! testShortFunctions should only be used with --resamp TRUE\n" );
284 printf( "Proceeding, but unexpected behavior may follow...\n" );
285 if ( uvar.treatWarningsAsErrors ) {
286 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
288 }
289 }
290 if ( ( uvar.resamp == FALSE ) && ( uvar.alignTShorts == TRUE ) ) {
291 printf( "Warning! alignTShorts should only be used with --resamp TRUE\n" );
292 printf( "Proceeding without resampling...\n" );
293 if ( uvar.treatWarningsAsErrors ) {
294 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
296 }
297 }
298 if ( ( uvar.resamp == FALSE ) && ( uvar.accurateResampMetric == TRUE ) ) {
299 printf( "Warning! accurateResampMetric should only be used with --resamp TRUE\n" );
300 printf( "Proceeding without resampling...\n" );
301 if ( uvar.treatWarningsAsErrors ) {
302 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
304 }
305 }
306 UINT4 numShortPerDet = 0;
307 if ( ( numShortPerDet = XLALCrossCorrNumShortPerDetector( resampTshort, uvar.startTime, uvar.endTime ) ) == 0 ) {
308 LogPrintf( LOG_CRITICAL, "%s: XLALCrossCorrNumShortPerDetector() failed with errno=%d\n", __func__, xlalErrno );
310 }
311
312 if ( XLALUserVarWasSet( &uvar.spacingF ) && XLALUserVarWasSet( &uvar.mismatchF ) ) {
313 LogPrintf( LOG_CRITICAL, "spacingF and mismatchF are both set, use spacingF %.9g by default\n\n", uvar.spacingF );
314 }
315 if ( XLALUserVarWasSet( &uvar.spacingA ) && XLALUserVarWasSet( &uvar.mismatchA ) ) {
316 LogPrintf( LOG_CRITICAL, "spacingA and mismatchA are both set, use spacingA %.9g by default\n\n", uvar.spacingA );
317 }
318 if ( XLALUserVarWasSet( &uvar.spacingT ) && XLALUserVarWasSet( &uvar.mismatchT ) ) {
319 LogPrintf( LOG_CRITICAL, "spacingT and mismatchT are both set, use spacingT %.9g by default\n\n", uvar.spacingT );
320 }
321 if ( XLALUserVarWasSet( &uvar.spacingP ) && XLALUserVarWasSet( &uvar.mismatchP ) ) {
322 LogPrintf( LOG_CRITICAL, "spacingP and mismatchP are both set, use spacingP %.9g by default\n\n", uvar.spacingP );
323 }
324
325 if ( uvar.useLattice == FALSE ) {
326 if ( !XLALUserVarWasSet( &uvar.spacingF ) && !XLALUserVarWasSet( &uvar.mismatchF ) ) {
327 LogPrintf( LOG_CRITICAL, "neither spacingF nor mismatchF was set, using mismatchF %.9g by default\n\n", uvar.mismatchF );
328 if ( uvar.treatWarningsAsErrors ) {
329 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
331 }
332 }
333 if ( !XLALUserVarWasSet( &uvar.spacingA ) && !XLALUserVarWasSet( &uvar.mismatchA ) ) {
334 LogPrintf( LOG_CRITICAL, "neither spacingA nor mismatchA was set, using mismatchA %.9g by default\n\n", uvar.mismatchA );
335 if ( uvar.treatWarningsAsErrors ) {
336 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
338 }
339 }
340 if ( !XLALUserVarWasSet( &uvar.spacingT ) && !XLALUserVarWasSet( &uvar.mismatchT ) ) {
341 LogPrintf( LOG_CRITICAL, "neither spacingT nor mismatchT was set, using mismatchT %.9g by default\n\n", uvar.mismatchT );
342 if ( uvar.treatWarningsAsErrors ) {
343 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
345 }
346 }
347 if ( !XLALUserVarWasSet( &uvar.spacingP ) && !XLALUserVarWasSet( &uvar.mismatchP ) ) {
348 LogPrintf( LOG_CRITICAL, "neither spacingP nor mismatchP was set, using mismatchP %.9g by default\n\n", uvar.mismatchP );
349 if ( uvar.treatWarningsAsErrors ) {
350 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
352 }
353 }
354 }
355
356 if ( uvar.resamp == TRUE && uvar.useLattice == TRUE ) {
357 printf( "Error! LatticeTiling placement not yet implemented with resampling\n" );
359 }
360
361 if ( uvar.useLattice == TRUE
362 && uvar.mismatchMax < uvar.unresolvedPorbMismatch ) {
363 printf( "Error! Unresolved P threshold (%g) exceeds max mismatch (%g)",
364 uvar.unresolvedPorbMismatch, uvar.mismatchMax );
366 }
367
368 /* create the toplist */
369 create_crossCorrBinary_toplist( &ccToplist, uvar.numCand );
370 /* now read the data */
371
372 /* /\* get SFT parameters so that we can initialise search frequency resolutions *\/ */
373 /* /\* calculate deltaF_SFT *\/ */
374 /* deltaF_SFT = catalog->data[0].header.deltaF; /\* frequency resolution *\/ */
375 /* timeBase= 1.0/deltaF_SFT; /\* sft baseline *\/ */
376
377 /* /\* catalog is ordered in time so we can get start, end time and tObs *\/ */
378 /* firstTimeStamp = catalog->data[0].header.epoch; */
379 /* lastTimeStamp = catalog->data[catalog->length - 1].header.epoch; */
380 /* tObs = XLALGPSDiff( &lastTimeStamp, &firstTimeStamp ) + timeBase; */
381
382 /* /\*set pulsar reference time *\/ */
383 /* if (XLALUserVarWasSet ( &uvar_refTime )) { */
384 /* XLALGPSSetREAL8(&refTime, uvar_refTime); */
385 /* } */
386 /* else { /\*if refTime is not set, set it to midpoint of sfts*\/ */
387 /* XLALGPSSetREAL8(&refTime, (0.5*tObs) + XLALGPSGetREAL8(&firstTimeStamp)); */
388 /* } */
389
390 /* /\* set frequency resolution defaults if not set by user *\/ */
391 /* if (!(XLALUserVarWasSet (&uvar_fResolution))) { */
392 /* uvar_fResolution = 1/tObs; */
393 /* } */
394
395 /* { */
396 /* /\* block for calculating frequency range to read from SFTs *\/ */
397 /* /\* user specifies freq and fdot range at reftime */
398 /* we translate this range of fdots to start and endtime and find */
399 /* the largest frequency band required to cover the */
400 /* frequency evolution *\/ */
401 /* PulsarSpinRange spinRange_startTime; /\**< freq and fdot range at start-time of observation *\/ */
402 /* PulsarSpinRange spinRange_endTime; /\**< freq and fdot range at end-time of observation *\/ */
403 /* PulsarSpinRange spinRange_refTime; /\**< freq and fdot range at the reference time *\/ */
404
405 /* REAL8 startTime_freqLo, startTime_freqHi, endTime_freqLo, endTime_freqHi, freqLo, freqHi; */
406
407 /* REAL8Vector *fdotsMin=NULL; */
408 /* REAL8Vector *fdotsMax=NULL; */
409
410 /* UINT4 k; */
411
412 /* fdotsMin = (REAL8Vector *)LALCalloc(1, sizeof(REAL8Vector)); */
413 /* fdotsMin->length = N_SPINDOWN_DERIVS; */
414 /* fdotsMin->data = (REAL8 *)LALCalloc(fdotsMin->length, sizeof(REAL8)); */
415
416 /* fdotsMax = (REAL8Vector *)LALCalloc(1, sizeof(REAL8Vector)); */
417 /* fdotsMax->length = N_SPINDOWN_DERIVS; */
418 /* fdotsMax->data = (REAL8 *)LALCalloc(fdotsMax->length, sizeof(REAL8)); */
419
420 /* XLAL_INIT_MEM(spinRange_startTime); */
421 /* XLAL_INIT_MEM(spinRange_endTime); */
422 /* XLAL_INIT_MEM(spinRange_refTime); */
423
424 /* spinRange_refTime.refTime = refTime; */
425 /* spinRange_refTime.fkdot[0] = uvar_f0; */
426 /* spinRange_refTime.fkdotBand[0] = uvar_fBand; */
427 /* } */
428
429 /* FIXME: need to correct fMin and fMax for Doppler shift, rngmedian bins and spindown range */
430 /* this is essentially just a place holder for now */
431 /* FIXME: this running median buffer is overkill, since the running median block need not be centered on the search frequency */
432 /* Note by GDM: above two "fixme" statements appear resolved, but have been left
433 * in place pending contact with original author */
434 REAL8 vMax = LAL_TWOPI * ( uvar.orbitAsiniSec + uvar.orbitAsiniSecBand ) / config.orbitPSecMin + LAL_TWOPI * LAL_REARTH_SI / ( LAL_DAYSID_SI * LAL_C_SI ) + LAL_TWOPI * LAL_AU_SI / ( LAL_YRSID_SI * LAL_C_SI ); /*calculate the maximum relative velocity in speed of light*/
435 fMin = uvar.fStart * ( 1 - vMax ) - 0.5 * uvar.rngMedBlock * deltaF;
436 fMax = ( uvar.fStart + uvar.fBand ) * ( 1 + vMax ) + 0.5 * uvar.rngMedBlock * deltaF;
437
438 /* read the SFTs*/
439 if ( ( inputSFTs = XLALLoadMultiSFTs( config.catalog, fMin, fMax ) ) == NULL ) {
440 LogPrintf( LOG_CRITICAL, "%s: XLALLoadMultiSFTs() failed with errno=%d\n", __func__, xlalErrno );
442 }
443
444
445 /* read the timestamps from the SFTs */
446 if ( ( multiTimes = XLALExtractMultiTimestampsFromSFTs( inputSFTs ) ) == NULL ) {
447 LogPrintf( LOG_CRITICAL, "%s: XLALExtractMultiTimestampsFromSFTs() failed with errno=%d\n", __func__, xlalErrno );
449 }
450
451 /* read the detector information from the SFTs */
452 if ( XLALMultiLALDetectorFromMultiSFTs( &multiDetectors, inputSFTs ) != XLAL_SUCCESS ) {
453 LogPrintf( LOG_CRITICAL, "%s: XLALMultiLALDetectorFromMultiSFTs() failed with errno=%d\n", __func__, xlalErrno );
455 }
456
457 /* inject signals for demod if specified (resamp injects them later) */
458 if ( XLALUserVarWasSet( &uvar.injectionSources ) && ( uvar.resamp != TRUE ) ) {
459 PulsarParamsVector *injectSources = NULL;
460 if ( ( injectSources = XLALPulsarParamsFromUserInput( uvar.injectionSources, NULL ) ) == NULL ) {
461 LogPrintf( LOG_CRITICAL, "%s: XLALPulsarParamsFromUserInput() failed with errno=%d\n", __func__, xlalErrno );
463 }
464 CWMFDataParams XLAL_INIT_DECL( MFDparams );
465 const SFTtype *sft = &inputSFTs->data[0]->data[0];
466 MFDparams.fMin = sft->f0;
467 MFDparams.Band = sft->data->length * sft->deltaF;
468 MFDparams.multiIFO = multiDetectors;
469 MFDparams.multiTimestamps = multiTimes;
470
471 MFDparams.multiNoiseFloor.length = multiDetectors.length;
472
473 MultiSFTVector *fakeMultiSFTs = NULL;
474 if ( XLALCWMakeFakeMultiData( &fakeMultiSFTs, NULL, injectSources, &MFDparams, config.edat ) != XLAL_SUCCESS ) {
475 LogPrintf( LOG_CRITICAL, "%s: XLALCWMakeFakeMultiData() failed with errno=%d\n", __func__, xlalErrno );
477 }
478
479 if ( XLALMultiSFTVectorAdd( inputSFTs, fakeMultiSFTs ) != XLAL_SUCCESS ) {
480 LogPrintf( LOG_CRITICAL, "%s: XLALMultiSFTVectorAdd() failed with errno=%d\n", __func__, xlalErrno );
482 }
483
484 XLALDestroyMultiSFTVector( fakeMultiSFTs );
485 XLALDestroyPulsarParamsVector( injectSources );
486 }
487
488 /* calculate the psd and normalize the SFTs */
489 if ( ( multiPSDs = XLALNormalizeMultiSFTVect( inputSFTs, uvar.rngMedBlock, NULL ) ) == NULL ) {
490 LogPrintf( LOG_CRITICAL, "%s: XLALNormalizeMultiSFTVect() failed with errno=%d\n", __func__, xlalErrno );
492 }
493
494 /* compute the noise weights for the AM coefficients */
495 if ( ( multiWeights = XLALComputeMultiNoiseWeights( multiPSDs, uvar.rngMedBlock, 0 ) ) == NULL ) {
496 LogPrintf( LOG_CRITICAL, "%s: XLALComputeMultiNoiseWeights() failed with errno=%d\n", __func__, xlalErrno );
498 }
499 XLALDestroyMultiPSDVector( multiPSDs );
500
501 /* Find the detector state for each SFT */
502 /* Offset by Tsft/2 to get midpoint as timestamp */
503 if ( ( multiStates = XLALGetMultiDetectorStates( multiTimes, &multiDetectors, config.edat, 0.5 * Tsft ) ) == NULL ) {
504 LogPrintf( LOG_CRITICAL, "%s: XLALGetMultiDetectorStates() failed with errno=%d\n", __func__, xlalErrno );
506 }
507
508 /* Note this is specialized to a single sky position */
509 /* This might need to be moved into the config variables */
510 skyPos.system = COORDINATESYSTEM_EQUATORIAL;
511 skyPos.longitude = uvar.alphaRad;
512 skyPos.latitude = uvar.deltaRad;
513
514 /* For resampling with tShort, generate appropriate times, states, and coefficients */
515 if ( ( uvar.resamp == TRUE ) && ( uvar.testResampNoTShort == FALSE ) ) {
516 /* Edit the timestamps to accurately reflect tShort */
517 if ( ( resampMultiTimes = XLALGenerateMultiTshortTimestamps( multiTimes, resampTshort, numShortPerDet, uvar.alignTShorts ) ) == NULL ) {
518 LogPrintf( LOG_CRITICAL, "%s: XLALModifyMultiTimestampsFromSFTs() failed with errno=%d\n", __func__, xlalErrno );
520 }
521 if ( ( resampMultiWeights = XLALModifyMultiWeights( multiWeights, resampTshort, Tsft, numShortPerDet, multiTimes ) ) == NULL ) {
522 LogPrintf( LOG_CRITICAL, "%s: XLALModifyMultiWeights() failed with errno=%d\n", __func__, xlalErrno );
524 }
525 /* Get correct multi-detector states for tShort */
526 if ( ( resampMultiStates = XLALGetMultiDetectorStates( resampMultiTimes, &multiDetectors, config.edat, 0.5 * resampTshort ) ) == NULL ) {
527 LogPrintf( LOG_CRITICAL, "%s: XLALGetMultiDetectorStates() failed with errno=%d\n", __func__, xlalErrno );
529 }
530 /* Calculate the AM coefficients (a,b) for each SFT */
531 if ( ( resampMultiCoeffs = XLALComputeMultiAMCoeffs( resampMultiStates, resampMultiWeights, skyPos ) ) == NULL ) {
532 LogPrintf( LOG_CRITICAL, "%s: XLALComputeMultiAMCoeffs() failed with errno=%d\n", __func__, xlalErrno );
534 }
535 }
536
537 if ( ( uvar.resamp == FALSE ) || ( uvar.accurateResampMetric == TRUE ) ) {
538 /* Calculate the AM coefficients (a,b) for each SFT */
539 if ( ( multiCoeffs = XLALComputeMultiAMCoeffs( multiStates, multiWeights, skyPos ) ) == NULL ) {
540 LogPrintf( LOG_CRITICAL, "%s: XLALComputeMultiAMCoeffs() failed with errno=%d\n", __func__, xlalErrno );
542 }
543 }
544
545 /* Construct the flat list of SFTs (this sort of replicates the
546 catalog, but there's not an obvious way to get the information
547 back) */
548
549 if ( ( XLALCreateSFTIndexListFromMultiSFTVect( &sftIndices, inputSFTs ) != XLAL_SUCCESS ) ) {
550 LogPrintf( LOG_CRITICAL, "%s: XLALCreateSFTIndexListFromMultiSFTVect() failed with errno=%d\n", __func__, xlalErrno );
552 }
553 UINT4 numSFTs = sftIndices->length;
554
555 /* Construct the list of SFT pairs */
556#define PCC_SFTPAIR_HEADER "# The length of SFT-pair list is %u #\n"
557#define PCC_SFTPAIR_BODY "%u %u\n"
558#define PCC_SFT_HEADER "# The length of SFT list is %u #\n"
559#define PCC_SFT_BODY "%s %d %d\n"
560 FILE *fp = NULL;
561
562 if ( XLALUserVarWasSet( &uvar.pairListInputFilename ) ) { /* If the user provided a list for reading, use it */
563 if ( uvar.resamp == TRUE ) {
564 LogPrintf( LOG_CRITICAL, "Error! Reading pair list from input file not supported with resampling.\n" );
566 }
567 if ( ( sftPairs = XLALCalloc( 1, sizeof( sftPairs ) ) ) == NULL ) {
569 }
570 if ( ( fp = fopen( uvar.pairListInputFilename, "r" ) ) == NULL ) {
571 LogPrintf( LOG_CRITICAL, "didn't find SFT-pair list file with given input name\n" );
573 }
574 if ( fscanf( fp, PCC_SFTPAIR_HEADER, &sftPairs->length ) == EOF ) {
575 LogPrintf( LOG_CRITICAL, "can't read the length of SFT-pair list from the header\n" );
577 }
578
579 if ( ( sftPairs->data = XLALCalloc( sftPairs->length, sizeof( *sftPairs->data ) ) ) == NULL ) {
580 XLALFree( sftPairs );
582 }
583
584 for ( j = 0; j < sftPairs->length; j++ ) { /*read in the SFT-pair list */
585 if ( fscanf( fp, PCC_SFTPAIR_BODY, &sftPairs->data[j].sftNum[0], &sftPairs->data[j].sftNum[1] ) == EOF ) {
586 LogPrintf( LOG_CRITICAL, "The length of SFT-pair list doesn't match!" );
588 }
589 }
590 fclose( fp );
591 } else { /* if not, construct the list of pairs */
592 if ( uvar.resamp == TRUE ) {
593 if ( uvar.testResampNoTShort == FALSE ) {
594 /* Run modified pair maker for resampling with tShort */
595 if ( ( XLALCreateSFTPairIndexListShortResamp( &resampMultiPairs, uvar.maxLag, uvar.inclAutoCorr, uvar.inclSameDetector, Tsft, resampMultiTimes ) != XLAL_SUCCESS ) ) {
596 LogPrintf( LOG_CRITICAL, "%s: XLALCreateSFTPairIndexListShortResamp() failed with errno=%d\n", __func__, xlalErrno );
598 }
599 if ( uvar.accurateResampMetric == TRUE ) {
600 /* printf("About to call XLALCreateSFTPairIndexListAccurateResamp\n"); */
601 if ( ( XLALCreateSFTPairIndexListAccurateResamp( &sftPairs, &sftPairForTshortPair, sftIndices, resampMultiPairs, multiTimes, resampMultiTimes ) != XLAL_SUCCESS ) ) {
602 LogPrintf( LOG_CRITICAL, "%s: XLALCreateSFTPairIndexListAccurateResamp() failed with errno=%d\n", __func__, xlalErrno );
604 }
605 }
606 /* Assign old-school structures */
607 tShortPairs = resampMultiPairs->pairIndexList;
608 tShortIndices = resampMultiPairs->indexList;
609 } else {
610 XLALDestroySFTPairIndexList( sftPairs );
611 if ( ( XLALCreateSFTPairIndexListResamp( &resampMultiPairs, &sftPairs, sftIndices, inputSFTs, uvar.maxLag, uvar.inclAutoCorr, uvar.inclSameDetector, Tsft, resampTshort ) != XLAL_SUCCESS ) ) {
612 LogPrintf( LOG_CRITICAL, "%s: XLALCreateSFTPairIndexListResamp() failed with errno=%d\n", __func__, xlalErrno );
614 }
615 }
616 } else {
617 if ( ( XLALCreateSFTPairIndexList( &sftPairs, sftIndices, inputSFTs, uvar.maxLag, uvar.inclAutoCorr ) != XLAL_SUCCESS ) ) {
618 LogPrintf( LOG_CRITICAL, "%s: XLALCreateSFTPairIndexList() failed with errno=%d\n", __func__, xlalErrno );
620 }
621 }
622 }
623 if ( XLALUserVarWasSet( &uvar.pairListOutputFilename ) ) { /* Write the list of pairs to a file, if a name was provided */
624 if ( ( fp = fopen( uvar.pairListOutputFilename, "w" ) ) == NULL ) {
625 LogPrintf( LOG_CRITICAL, "Can't write in SFT-pair list \n" );
627 }
628 if ( sftPairs == NULL ) {
629 LogPrintf( LOG_CRITICAL, "No pair list available to write (are you using --resamp without --accurateResampMetric?)" );
630 if ( uvar.treatWarningsAsErrors ) {
631 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
633 }
634 }
635 fprintf( fp, PCC_SFTPAIR_HEADER, sftPairs->length ); /*output the length of SFT-pair list to the header*/
636 for ( j = 0; j < sftPairs->length; j++ ) {
637 fprintf( fp, PCC_SFTPAIR_BODY, sftPairs->data[j].sftNum[0], sftPairs->data[j].sftNum[1] );
638 }
639 fclose( fp );
640 }
641 if ( XLALUserVarWasSet( &uvar.resampPairListOutputFilename ) ) { /* Write the list of pairs to a file, if a name was provided */
642 if ( ( fp = fopen( uvar.resampPairListOutputFilename, "w" ) ) == NULL ) {
643 LogPrintf( LOG_CRITICAL, "Can't write in SFT-pair list \n" );
645 }
646 if ( tShortPairs == NULL ) {
647 LogPrintf( LOG_CRITICAL, "No Tshort pair list available to write (are you not using --resamp?)" );
648 if ( uvar.treatWarningsAsErrors ) {
649 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
651 }
652 }
653 fprintf( fp, PCC_SFTPAIR_HEADER, tShortPairs->length ); /*output the length of SFT-pair list to the header*/
654 for ( j = 0; j < tShortPairs->length; j++ ) {
655 fprintf( fp, PCC_SFTPAIR_BODY, tShortPairs->data[j].sftNum[0], tShortPairs->data[j].sftNum[1] );
656 }
657 fclose( fp );
658 }
659
660 if ( XLALUserVarWasSet( &uvar.sftListOutputFilename ) ) { /* Write the list of SFTs to a file for sanity-checking purposes */
661 if ( ( fp = fopen( uvar.sftListOutputFilename, "w" ) ) == NULL ) {
662 LogPrintf( LOG_CRITICAL, "Can't write in flat SFT list \n" );
664 }
665 fprintf( fp, PCC_SFT_HEADER, numSFTs ); /*output the length of SFT list to the header*/
666 for ( j = 0; j < numSFTs; j++ ) { /*output the SFT list */
667 fprintf( fp, PCC_SFT_BODY, inputSFTs->data[sftIndices->data[j].detInd]->data[0].name, multiTimes->data[sftIndices->data[j].detInd]->data[sftIndices->data[j].sftInd].gpsSeconds, multiTimes->data[sftIndices->data[j].detInd]->data[sftIndices->data[j].sftInd].gpsNanoSeconds );
668 }
669 fclose( fp );
670 } else if ( XLALUserVarWasSet( &uvar.sftListInputFilename ) ) { /*do a sanity check of the order of SFTs list if the name of input SFT list is given*/
671 UINT4 numofsft = 0;
672 if ( ( fp = fopen( uvar.sftListInputFilename, "r" ) ) == NULL ) {
673 LogPrintf( LOG_CRITICAL, "Can't read in flat SFT list \n" );
675 }
676 if ( fscanf( fp, PCC_SFT_HEADER, &numofsft ) == EOF ) {
677 LogPrintf( LOG_CRITICAL, "can't read in the length of SFT list from header\n" );
679 }
680
681 CHARVectorSequence *checkDet = NULL;
682 if ( ( checkDet = XLALCreateCHARVectorSequence( numofsft, LALNameLength ) ) == NULL ) {
683 LogPrintf( LOG_CRITICAL, "%s: XLALCreateCHARVector() failed with errno=%d\n", __func__, xlalErrno );
685 }
686 INT4 checkGPS[numofsft], checkGPSns[numofsft];
687 if ( numofsft == numSFTs ) {
688 for ( j = 0; j < numofsft; j++ ) {
689 if ( fscanf( fp, PCC_SFT_BODY, &checkDet->data[j * LALNameLength], &checkGPS[j], &checkGPSns[j] ) == EOF ) {
690 LogPrintf( LOG_CRITICAL, "The length of SFT list doesn't match\n" );
692 }
693 if ( strcmp( inputSFTs->data[sftIndices->data[j].detInd]->data[sftIndices->data[j].sftInd].name, &checkDet->data[j * LALNameLength] ) != 0
694 || inputSFTs->data[sftIndices->data[j].detInd]->data[sftIndices->data[j].sftInd].epoch.gpsSeconds != checkGPS[j]
695 || inputSFTs->data[sftIndices->data[j].detInd]->data[sftIndices->data[j].sftInd].epoch.gpsNanoSeconds != checkGPSns[j] ) {
696 LogPrintf( LOG_CRITICAL, "The order of SFTs has been changed, it's the end of civilization\n" );
698 }
699 }
700 fclose( fp );
702 } else {
703 LogPrintf( LOG_CRITICAL, "Run for your life, the length of SFT list doesn't match" );
705 }
706 }
707
708 if ( XLALUserVarWasSet( &uvar.tShortListOutputFilename ) ) { /* Write the list of SFTs to a file for sanity-checking purposes */
709 if ( ( fp = fopen( uvar.tShortListOutputFilename, "w" ) ) == NULL ) {
710 LogPrintf( LOG_CRITICAL, "Can't write in flat SFT list \n" );
712 }
713 fprintf( fp, PCC_SFT_HEADER, tShortIndices->length ); /*output the length of TSHORT list to the header*/
714 for ( j = 0; j < tShortIndices->length; j++ ) { /*output the TSHORT list */
715 fprintf( fp, PCC_SFT_BODY, inputSFTs->data[tShortIndices->data[j].detInd]->data[0].name, resampMultiTimes->data[tShortIndices->data[j].detInd]->data[tShortIndices->data[j].sftInd].gpsSeconds, resampMultiTimes->data[tShortIndices->data[j].detInd]->data[tShortIndices->data[j].sftInd].gpsNanoSeconds );
716 }
717 fclose( fp );
718 }
719
720 /* Parse the list of lines to avoid (if given) */
721
722 MultiUINT4Vector *badBins = NULL;
723
724#define PCC_LINEFILE_HEADER "%% %2s lines cleaning file for %s\n"\
725"%%\n"\
726"%% File contains %d (non-comment) lines\n"\
727"%%\n"\
728"%% Column 1 - frequency spacing (Hz) of comb (or frequency of single line)\n"\
729"%% Column 2 - comb type (0 - singlet, 1 - comb with fixed width, 2 - comb with scaling width)\n"\
730"%% Column 3 - frequency offset of 1st visible harmonic (Hz)\n"\
731"%% Column 4 - index of first visible harmonic\n"\
732"%% Column 5 - index of last visible harmonic\n"\
733"%% Column 6 - width of left band (Hz)\n"\
734"%% Column 7 - width of right band (Hz)\n"\
735"%%\n"\
736"%% For fixed-width combs, veto the band:\n"\
737"%% [offset+index*spacing-leftwidth, offset+index*spacing+rightwidth]\n"\
738"%% For scaling-width combs, veto the band:\n"\
739"%% [offset+index*spacing-index*leftwidth, offset+index*spacing+index*rightwidth]\n"\
740"%%"
741#define PCC_LINEFILE_BODY "%lf %d %lf %d %d %lf %lf"
742
743 if ( config.lineFiles != NULL ) {
744 if ( ( badBins = XLALCalloc( 1, sizeof( badBins ) ) ) == NULL ) {
746 }
747 UINT4 numDets = inputSFTs->length;
748 badBins->length = numDets;
749 if ( ( badBins->data = XLALCalloc( numDets, sizeof( *badBins->data ) ) ) == NULL ) {
751 }
752
753 for ( UINT4 i_f = 0 ; i_f < config.lineFiles->length ; i_f++ ) {
754 /* printf("i_f=%d\n",i_f); */
755 if ( ( fp = fopen( config.lineFiles->data[i_f], "r" ) ) == NULL ) {
756 LogPrintf( LOG_CRITICAL, "%s: didn't find line file with name %s\n", __func__, config.lineFiles->data[i_f] );
758 }
759 CHAR ifo[3];
760 UINT4 numLines;
761 CHAR linesLabel;
762 if ( fscanf( fp, PCC_LINEFILE_HEADER, &ifo[0], &linesLabel, &numLines ) == EOF ) {
763 LogPrintf( LOG_CRITICAL, "can't parse header of line file %s\n", config.lineFiles->data[i_f] );
765 }
766 fclose( fp );
767
768 UINT4 detInd = 0;
769 for ( ; detInd < numDets ; detInd++ ) {
770 if ( strcmp( ifo, inputSFTs->data[detInd]->data[0].name ) == 0 ) {
771 break;
772 }
773 } /*find the detctor index of the ifo and break the loop*/
774 if ( detInd >= numDets ) {
775 LogPrintf( LOG_CRITICAL, "%s: didn't find index for IFO %s\n", __func__, ifo );
777 }
778 UINT4 numSFTFreqs = inputSFTs->data[detInd]->data[0].data->length;
779 REAL8 f0 = inputSFTs->data[detInd]->data[0].f0;
780 if ( deltaF != inputSFTs->data[detInd]->data[0].deltaF ) {
781 LogPrintf( LOG_CRITICAL, "%s: deltaF = %f disagrees with SFT deltaF = %f", __func__, deltaF, inputSFTs->data[detInd]->data[0].deltaF );
783 }
784
785 if ( ( badBins->data[detInd] = XLALCreateUINT4Vector( numSFTFreqs ) ) == NULL ) {
786 LogPrintf( LOG_CRITICAL, "%s: XLALCreateUINT4Vector() failed with errno=%d\n", __func__, xlalErrno );
788 }
789 /* printf("%d\n",badBins->data[detInd]->length); */
790 INT4 binCount = 0;
791
792 if ( ( fp = fopen( config.lineFiles->data[i_f], "r" ) ) == NULL ) {
793 LogPrintf( LOG_CRITICAL, "%s: didn't find line file with name %s\n", __func__, config.lineFiles->data[i_f] );
795 }
796 CHAR thisline[MAXLINELENGTH];
797 UINT4 linesRead = 0;
798 while ( fgets( thisline, sizeof thisline, fp ) ) {
799 if ( thisline[0] == '%' ) {
800 continue;
801 }
802 REAL8 spacing;
803 UINT4 combtype;
804 REAL8 offset;
805 UINT4 firstindex, lastindex;
806 REAL8 leftwidth, rightwidth;
807 UINT4 numRead = sscanf( thisline, PCC_LINEFILE_BODY, &spacing, &combtype, &offset, &firstindex, &lastindex, &leftwidth, &rightwidth );
808 if ( numRead != 7 ) {
809 LogPrintf( LOG_CRITICAL, "Failed to read data out of line file %s: needed 7, got %d\n", config.lineFiles->data[i_f], numRead );
811 }
812 /* printf(PCC_LINEFILE_BODY "\n", spacing, combtype, offset, firstindex, lastindex, leftwidth, rightwidth); */
813 switch ( combtype ) {
814 case 0: /* singlet line */
815 if ( firstindex != lastindex ) {
816 LogPrintf( LOG_CRITICAL, "Error in file %s: singlet line with firstindex=%d,lastindex=%d\n", config.lineFiles->data[i_f], firstindex, lastindex );
818 }
819 binCount = XLALFindBadBins( badBins->data[detInd], binCount, offset + firstindex * spacing - leftwidth, offset + lastindex * spacing + rightwidth, f0, deltaF, numSFTFreqs );
820 if ( binCount < 0 ) {
821 LogPrintf( LOG_CRITICAL, "%s: XLALFindBadBins() failed with errno=%d\n", __func__, xlalErrno );
823 }
824 /* printf ("veto %f to %f\n", offset+firstindex*spacing-leftwidth, offset+lastindex*spacing+rightwidth); */
825 break;
826 case 1: /* fixed-width comb */
827 if ( firstindex > lastindex ) {
828 LogPrintf( LOG_CRITICAL, "Error in file %s: comb with firstindex=%d,lastindex=%d\n", config.lineFiles->data[i_f], firstindex, lastindex );
830 }
831 for ( UINT4 index0 = firstindex ; index0 <= lastindex; index0++ ) {
832 binCount = XLALFindBadBins( badBins->data[detInd], binCount, offset + index0 * spacing - leftwidth, offset + index0 * spacing + rightwidth, f0, deltaF, numSFTFreqs );
833 if ( binCount < 0 ) {
834 LogPrintf( LOG_CRITICAL, "%s: XLALFindBadBins() failed with errno=%d\n", __func__, xlalErrno );
836 }
837 /* printf ("veto %f to %f\n", offset+index0*spacing-leftwidth, offset+index0*spacing+rightwidth); */
838 }
839 break;
840 case 2: /* scaling-width comb */
841 if ( firstindex > lastindex ) {
842 LogPrintf( LOG_CRITICAL, "Error in file %s: comb with firstindex=%d,lastindex=%d\n", config.lineFiles->data[i_f], firstindex, lastindex );
844 }
845 for ( UINT4 index0 = firstindex ; index0 <= lastindex; index0++ ) {
846 binCount = XLALFindBadBins( badBins->data[detInd], binCount, offset + index0 * spacing - index0 * leftwidth, offset + index0 * spacing + index0 * rightwidth, f0, deltaF, numSFTFreqs );
847 if ( binCount < 0 ) {
848 LogPrintf( LOG_CRITICAL, "%s: XLALFindBadBins() failed with errno=%d\n", __func__, xlalErrno );
850 }
851 /* printf ("veto %f to %f\n", offset+index0*spacing-index0*leftwidth, offset+index0*spacing+index0*rightwidth); */
852 }
853 break;
854 default:
855 LogPrintf( LOG_CRITICAL, "Unrecognized combtype %d\n", combtype );
857 }
858
859 linesRead++;
860 } /* while (fgets(thisline, sizeof thisline, fp)) */
861 if ( linesRead != numLines ) {
862 LogPrintf( LOG_CRITICAL, "Read %d lines out of %s but expected %d", linesRead, config.lineFiles->data[i_f], numLines );
864 }
865 if ( binCount == 0 ) {
866 XLALDestroyUINT4Vector( badBins->data[detInd] );
867 badBins->data[detInd] = NULL;
868 } else {
869 if ( ( badBins->data[detInd]->data = XLALRealloc( badBins->data[detInd]->data, binCount * sizeof( UINT4 ) ) ) == NULL ) {
871 }
872 badBins->data[detInd]->length = binCount;
873 }
874 } /* for ( UINT4 i_f=0 ; i_f < config.lineFiles->length ; i_f++ ) */
875 } /* if ( config->lineFiles ) */
876
877 /* Get weighting factors for calculation of metric */
878 /* note that the sigma-squared is now absorbed into the curly G
879 because the AM coefficients are noise-weighted. */
880 REAL8Vector *GammaAve = NULL;
881 REAL8Vector *GammaCirc = NULL;
882 REAL8Vector *resampGammaAve = NULL;
883 REAL8Vector *resampGammaCirc = NULL;
884
885 /* printf("About to Calculate Gammmas\n"); */
886 if ( ( uvar.resamp == FALSE ) || ( uvar.accurateResampMetric == TRUE ) ) {
887 if ( ( XLALCalculateCrossCorrGammas( &GammaAve, &GammaCirc, sftPairs, sftIndices, multiCoeffs ) != XLAL_SUCCESS ) ) {
888 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateCrossCorrGammas() failed with errno=%d\n", __func__, xlalErrno );
890 }
891 if ( uvar.resamp == TRUE ) {
892 if ( ( XLALCombineCrossCorrGammas( &resampGammaAve, GammaAve, sftPairForTshortPair, Tsft, resampTshort ) != XLAL_SUCCESS ) ) {
893 LogPrintf( LOG_CRITICAL, "%s: XLALCombineCrossCorrGammas() failed with errno=%d\n", __func__, xlalErrno );
895 }
896 if ( ( XLALCombineCrossCorrGammas( &resampGammaCirc, GammaCirc, sftPairForTshortPair, Tsft, resampTshort ) != XLAL_SUCCESS ) ) {
897 LogPrintf( LOG_CRITICAL, "%s: XLALCombineCrossCorrGammas() failed with errno=%d\n", __func__, xlalErrno );
899 }
900 XLALDestroyUINT4VectorSequence( sftPairForTshortPair );
901 }
902 } else if ( uvar.testResampNoTShort == TRUE ) {
903 /* Cross-check valid only for gapless-Gaussian data */
904 if ( ( XLALCalculateCrossCorrGammasResamp( &resampGammaAve, &resampGammaCirc, resampMultiPairs, multiCoeffs ) != XLAL_SUCCESS ) ) {
905 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateCrossCorrGammasResamp() failed with errno=%d\n", __func__, xlalErrno );
907 }
908 } else {
909 if ( ( XLALCalculateCrossCorrGammas( &resampGammaAve, &resampGammaCirc, tShortPairs, tShortIndices, resampMultiCoeffs ) != XLAL_SUCCESS ) ) {
910 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateCrossCorrGammas() failed with errno=%d\n", __func__, xlalErrno );
912 }
913 }
914 /* printf("Calculated Gammmas\n"); */
915 XLALDestroyMultiAMCoeffs( multiCoeffs );
916 XLALDestroyMultiAMCoeffs( resampMultiCoeffs );
917 /* printf("Destroyed multiCoeffs\n"); */
918
919#define PCC_GAMMA_HEADER "# The normalization Sinv_Tsft is %g #\n"
920#define PCC_GAMMA_BODY "%.10g\n"
921 if ( XLALUserVarWasSet( &uvar.gammaAveOutputFilename ) ) { /* Write the aa+bb weight for each pair to a file, if a name was provided */
922 if ( ( fp = fopen( uvar.gammaAveOutputFilename, "w" ) ) == NULL ) {
923 LogPrintf( LOG_CRITICAL, "Can't write in Gamma_ave list \n" );
925 }
926 fprintf( fp, PCC_GAMMA_HEADER, multiWeights->Sinv_Tsft ); /*output the normalization factor to the header*/
927 for ( j = 0; j < sftPairs->length; j++ ) {
928 fprintf( fp, PCC_GAMMA_BODY, GammaAve->data[j] );
929 }
930 fclose( fp );
931 }
932 if ( XLALUserVarWasSet( &uvar.resampGammaAveOutputFilename ) ) { /* Write the aa+bb weight for each pair to a file, if a name was provided */
933 if ( ( fp = fopen( uvar.resampGammaAveOutputFilename, "w" ) ) == NULL ) {
934 LogPrintf( LOG_CRITICAL, "Can't write in Gamma_ave list \n" );
936 }
937 fprintf( fp, PCC_GAMMA_HEADER, resampMultiWeights->Sinv_Tsft ); /*output the normalization factor to the header*/
938 for ( j = 0; j < tShortPairs->length; j++ ) {
939 fprintf( fp, PCC_GAMMA_BODY, resampGammaAve->data[j] );
940 }
941 fclose( fp );
942 }
943 if ( XLALUserVarWasSet( &uvar.gammaCircOutputFilename ) ) { /* Write the ab-ba weight for each pair to a file, if a name was provided */
944 if ( ( fp = fopen( uvar.gammaCircOutputFilename, "w" ) ) == NULL ) {
945 LogPrintf( LOG_CRITICAL, "Can't write in Gamma_circ list \n" );
947 }
948 fprintf( fp, PCC_GAMMA_HEADER, multiWeights->Sinv_Tsft ); /*output the normalization factor to the header*/
949 for ( j = 0; j < sftPairs->length; j++ ) {
950 fprintf( fp, PCC_GAMMA_BODY, GammaCirc->data[j] );
951 }
952 fclose( fp );
953 }
954 if ( XLALUserVarWasSet( &uvar.resampGammaCircOutputFilename ) ) { /* Write the ab-ba weight for each pair to a file, if a name was provided */
955 if ( ( fp = fopen( uvar.resampGammaCircOutputFilename, "w" ) ) == NULL ) {
956 LogPrintf( LOG_CRITICAL, "Can't write in Gamma_circ list \n" );
958 }
959 fprintf( fp, PCC_GAMMA_HEADER, resampMultiWeights->Sinv_Tsft ); /*output the normalization factor to the header*/
960 for ( j = 0; j < tShortPairs->length; j++ ) {
961 fprintf( fp, PCC_GAMMA_BODY, resampGammaCirc->data[j] );
962 }
963 fclose( fp );
964 }
965
966 /*initialize binary parameters structure*/
967 XLAL_INIT_MEM( minBinaryTemplate );
968 XLAL_INIT_MEM( maxBinaryTemplate );
969 XLAL_INIT_MEM( thisBinaryTemplate );
970 XLAL_INIT_MEM( binaryTemplateSpacings );
971 /*fill in minbinaryOrbitParams*/
972 XLALGPSSetREAL8( &minBinaryTemplate.tp, uvar.orbitTimeAsc );
973 minBinaryTemplate.argp = 0.0;
974 minBinaryTemplate.asini = uvar.orbitAsiniSec;
975 minBinaryTemplate.ecc = 0.0;
976 minBinaryTemplate.period = config.orbitPSecMin;
977 minBinaryTemplate.fkdot[0] = uvar.fStart;
978 /*fill in maxBinaryParams*/
979 XLALGPSSetREAL8( &maxBinaryTemplate.tp, uvar.orbitTimeAsc + uvar.orbitTimeAscBand );
980 maxBinaryTemplate.argp = 0.0;
981 maxBinaryTemplate.asini = uvar.orbitAsiniSec + uvar.orbitAsiniSecBand;
982 maxBinaryTemplate.ecc = 0.0;
983 maxBinaryTemplate.period = config.orbitPSecMax;
984 maxBinaryTemplate.fkdot[0] = uvar.fStart + uvar.fBand;
985 /*fill in thisBinaryTemplate*/
986 XLALGPSSetREAL8( &thisBinaryTemplate.tp, uvar.orbitTimeAsc + 0.5 * uvar.orbitTimeAscBand );
987 thisBinaryTemplate.argp = 0.0;
988 thisBinaryTemplate.asini = 0.5 * ( minBinaryTemplate.asini + maxBinaryTemplate.asini );
989 thisBinaryTemplate.ecc = 0.0;
990 thisBinaryTemplate.period = 0.5 * ( minBinaryTemplate.period + maxBinaryTemplate.period );
991 thisBinaryTemplate.fkdot[0] = 0.5 * ( minBinaryTemplate.fkdot[0] + maxBinaryTemplate.fkdot[0] );
992
993 REAL8 old_diagff = 0; /*diagonal metric components*/
994 REAL8 old_diagaa = 0;
995 REAL8 old_diagTT = 0;
996 REAL8 old_diagpp = 0;
997 REAL8 ccStat = 0;
998 REAL8 evSquared = 0;
999 REAL8 estSens = 0; /*estimated sensitivity(4.13)*/
1000 REAL8 weightedMuTAve = 0;
1001
1002 /*Get metric diagonal components, also estimate sensitivity i.e. E[rho]/(h0)^2 (4.13)*/
1003 if ( ( uvar.resamp == TRUE ) && ( uvar.testResampNoTShort == FALSE ) ) {
1004 if ( uvar.accurateResampMetric == TRUE ) {
1005 if ( ( XLALCalculateLMXBCrossCorrDiagMetric( &estSens, &old_diagff, &old_diagaa, &old_diagTT, &old_diagpp, &weightedMuTAve, thisBinaryTemplate, GammaAve, sftPairs, sftIndices, inputSFTs, multiWeights /*, kappaValues*/ ) != XLAL_SUCCESS ) ) {
1006 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateLMXBCrossCorrDiagMetric() failed with errno=%d\n", __func__, xlalErrno );
1008 }
1009 } else {
1010 if ( ( XLALCalculateLMXBCrossCorrDiagMetricShort( &estSens, &old_diagff, &old_diagaa, &old_diagTT, &old_diagpp, thisBinaryTemplate, resampGammaAve, resampMultiPairs, resampMultiTimes, resampMultiWeights /*, kappaValues*/ ) != XLAL_SUCCESS ) ) {
1011 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateLMXBCrossCorrDiagMetricShort() failed with errno=%d\n", __func__, xlalErrno );
1013 }
1014 }
1015 } else {
1016 if ( ( XLALCalculateLMXBCrossCorrDiagMetric( &estSens, &old_diagff, &old_diagaa, &old_diagTT, &old_diagpp, &weightedMuTAve, thisBinaryTemplate, GammaAve, sftPairs, sftIndices, inputSFTs, multiWeights /*, kappaValues*/ ) != XLAL_SUCCESS ) ) {
1017 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateLMXBCrossCorrDiagMetric() failed with errno=%d\n", __func__, xlalErrno );
1019 }
1020 }
1021
1022 /* initialize the doppler scan struct which stores the current template information */
1023 XLALGPSSetREAL8( &dopplerpos.refTime, config.refTime );
1024 dopplerpos.Alpha = uvar.alphaRad;
1025 dopplerpos.Delta = uvar.deltaRad;
1026 dopplerpos.fkdot[0] = minBinaryTemplate.fkdot[0];
1027 /* set all spindowns to zero */
1028 for ( k = 1; k < PULSAR_MAX_SPINS; k++ ) {
1029 dopplerpos.fkdot[k] = 0.0;
1030 }
1031 dopplerpos.asini = minBinaryTemplate.asini;
1032 dopplerpos.period = minBinaryTemplate.period;
1033 dopplerpos.tp = minBinaryTemplate.tp;
1034 dopplerpos.ecc = minBinaryTemplate.ecc;
1035 dopplerpos.argp = minBinaryTemplate.argp;
1036
1037 /* Calculate SSB times (can do this once since search is currently only for one sky position, and binary doppler shift is added later) */
1038 MultiSSBtimes *multiSSBTimes = NULL;
1039 if ( ( uvar.resamp == FALSE ) || ( uvar.accurateResampMetric == TRUE ) ) {
1040 if ( ( multiSSBTimes = XLALGetMultiSSBtimes( multiStates, skyPos, dopplerpos.refTime, SSBPREC_RELATIVISTICOPT ) ) == NULL ) {
1041 LogPrintf( LOG_CRITICAL, "%s: XLALGetMultiSSBtimes() failed with errno=%d\n", __func__, xlalErrno );
1043 }
1044 } else {
1045 if ( ( multiSSBTimes = XLALGetMultiSSBtimes( resampMultiStates, skyPos, dopplerpos.refTime, SSBPREC_RELATIVISTICOPT ) ) == NULL ) {
1046 LogPrintf( LOG_CRITICAL, "%s: XLALGetMultiSSBtimes() failed with errno=%d\n", __func__, xlalErrno );
1048 }
1049 }
1050
1051 if ( uvar.resamp == FALSE ) {
1052 /* Allocate structure for binary doppler-shifting information */
1053 if ( ( multiBinaryTimes = XLALDuplicateMultiSSBtimes( multiSSBTimes ) ) == NULL ) {
1054 LogPrintf( LOG_CRITICAL, "%s: XLALDuplicateMultiSSBtimes() failed with errno=%d\n", __func__, xlalErrno );
1056 }
1057
1058 if ( ( shiftedFreqs = XLALCreateREAL8Vector( numSFTs ) ) == NULL ) {
1059 LogPrintf( LOG_CRITICAL, "%s: XLALCreateREAL8Vector() failed with errno=%d\n", __func__, xlalErrno );
1061 }
1062 if ( ( lowestBins = XLALCreateUINT4Vector( numSFTs ) ) == NULL ) {
1063 LogPrintf( LOG_CRITICAL, "%s: XLALCreateUINT4Vector() failed with errno=%d\n", __func__, xlalErrno );
1065 }
1066 if ( ( sincList = XLALCreateREAL8VectorSequence( numSFTs, uvar.numBins ) ) == NULL ) {
1067 LogPrintf( LOG_CRITICAL, "%s: XLALCreateREAL8VectorSequence() failed with errno=%d\n", __func__, xlalErrno );
1069 }
1070 }
1071
1072 /* "New" general metric computation */
1073 /* For now hard-code circular parameter space */
1074
1075 const DopplerCoordinateSystem coordSys = {
1076 .dim = 4,
1077 .coordIDs = {
1082 },
1083 };
1084
1085 REAL8VectorSequence *phaseDerivs = NULL;
1086
1087 if ( ( uvar.resamp == FALSE ) || ( uvar.accurateResampMetric == TRUE ) ) {
1088 if ( ( XLALCalculateCrossCorrPhaseDerivatives( &phaseDerivs, &thisBinaryTemplate, config.edat, sftIndices, multiSSBTimes, &coordSys ) != XLAL_SUCCESS ) ) {
1089 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateCrossCorrPhaseDerivatives() failed with errno=%d\n", __func__, xlalErrno );
1091 }
1092 } else {
1093 if ( ( XLALCalculateCrossCorrPhaseDerivatives( &phaseDerivs, &thisBinaryTemplate, config.edat, tShortIndices, multiSSBTimes, &coordSys ) != XLAL_SUCCESS ) ) {
1094 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateCrossCorrPhaseDerivatives() failed with errno=%d\n", __func__, xlalErrno );
1096 }
1097 }
1098
1099 /* fill in metric and parameter offsets */
1100 gsl_matrix *g_ij = NULL;
1101 gsl_vector *eps_i = NULL;
1102 REAL8 sumGammaSq = 0;
1103 if ( ( uvar.resamp == FALSE ) || ( uvar.accurateResampMetric == TRUE ) ) {
1104 if ( ( XLALCalculateCrossCorrPhaseMetric( &g_ij, &eps_i, &sumGammaSq, phaseDerivs, sftPairs, GammaAve, GammaCirc, &coordSys ) != XLAL_SUCCESS ) ) {
1105 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateCrossCorrPhaseMetric() failed with errno=%d\n", __func__, xlalErrno );
1107 }
1108 } else {
1109 if ( ( XLALCalculateCrossCorrPhaseMetric( &g_ij, &eps_i, &sumGammaSq, phaseDerivs, tShortPairs, resampGammaAve, resampGammaCirc, &coordSys ) != XLAL_SUCCESS ) ) {
1110 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateCrossCorrPhaseMetric() failed with errno=%d\n", __func__, xlalErrno );
1112 }
1113 }
1114
1115 /* Optional: call the test functions */
1116 if ( ( uvar.resamp == TRUE ) && ( uvar.testResampNoTShort == FALSE ) && ( uvar.testShortFunctions == TRUE ) ) {
1117 testShortFunctionsBlock( uvar, inputSFTs, Tsft, resampTshort, &sftIndices, &sftPairs, &GammaAve, &GammaCirc, &resampMultiPairs, &multiDetectors, &multiStates, &resampMultiStates, &multiWeights, &multiTimes, &resampMultiTimes, &multiSSBTimes, &phaseDerivs, &g_ij, &eps_i, estSens, &skyPos, &dopplerpos, &thisBinaryTemplate, config, coordSys );
1118 } /* results should be same as without testShortFunctions */
1119
1120 XLALDestroyREAL8VectorSequence( phaseDerivs );
1121 XLALDestroyREAL8Vector( resampGammaCirc );
1122 XLALDestroyREAL8Vector( GammaCirc );
1124 XLALDestroyMultiDetectorStateSeries( resampMultiStates );
1125 XLALDestroyMultiTimestamps( multiTimes );
1126 XLALDestroyMultiTimestamps( resampMultiTimes );
1127
1128 /* if ((fp = fopen("gsldata.dat","w"))==NULL){
1129 LogPrintf ( LOG_CRITICAL, "Can't write in gsl matrix file");
1130 XLAL_ERROR( XLAL_EFUNC );
1131 }
1132
1133 XLALfprintfGSLvector(fp, "%g", eps_i);
1134 XLALfprintfGSLmatrix(fp, "%g", g_ij);*/
1135 int ndim = 4;
1136 int dimT = 0;
1137 int dimP = 1;
1138 int dima = 2;
1139 int dimf = 3;
1140
1141 /* Modify metric if using sheared coordinates */
1142 if ( uvar.useShearedPorb == TRUE ) {
1143 REAL8 gTT = gsl_matrix_get( g_ij, dimT, dimT );
1144 REAL8 gTP = gsl_matrix_get( g_ij, dimT, dimP );
1145 REAL8 gPP = gsl_matrix_get( g_ij, dimP, dimP );
1146 config.unshearedgTT = gTT;
1147 config.unshearedgTP = gTP;
1148 REAL8 gtildeTT = gTT + 2. * config.dPorbdTascShear * gTP
1149 + SQR( config.dPorbdTascShear ) * gPP;
1150 REAL8 gtildeTP = gTP + config.dPorbdTascShear * gPP;
1151 gsl_matrix_set( g_ij, dimT, dimT, gtildeTT );
1152 gsl_matrix_set( g_ij, dimT, dimP, gtildeTP );
1153 gsl_matrix_set( g_ij, dimP, dimT, gtildeTP );
1154 }
1155
1156 REAL8 diagff = gsl_matrix_get( g_ij, dimf, dimf );
1157 REAL8 diagaa = gsl_matrix_get( g_ij, dima, dima );
1158 REAL8 diagTT = gsl_matrix_get( g_ij, dimT, dimT );
1159 REAL8 diagpp = gsl_matrix_get( g_ij, dimP, dimP );
1160
1161 dimName = XLALCreateCHARVector( coordSys.dim );
1162 dimName->data[0] = 'T';
1163 dimName->data[1] = 'p';
1164 dimName->data[2] = 'a';
1165 dimName->data[3] = 'f';
1166
1167 /* spacing in frequency from diagff */ /* set spacings in new dopplerparams struct */
1168 if ( XLALUserVarWasSet( &uvar.spacingF ) ) { /* If spacing was given by CMD line, use it, else calculate spacing by mismatch*/
1169 binaryTemplateSpacings.fkdot[0] = uvar.spacingF;
1170 } else {
1171 binaryTemplateSpacings.fkdot[0] = sqrt( uvar.mismatchF / diagff );
1172 }
1173
1174 if ( XLALUserVarWasSet( &uvar.spacingA ) ) {
1175 binaryTemplateSpacings.asini = uvar.spacingA;
1176 } else {
1177 binaryTemplateSpacings.asini = sqrt( uvar.mismatchA / diagaa );
1178 }
1179 if ( XLALUserVarWasSet( &uvar.spacingT ) ) {
1180 XLALGPSSetREAL8( &binaryTemplateSpacings.tp, uvar.spacingT );
1181 } else {
1182 XLALGPSSetREAL8( &binaryTemplateSpacings.tp, sqrt( uvar.mismatchT / diagTT ) );
1183 }
1184
1185 if ( XLALUserVarWasSet( &uvar.spacingP ) ) {
1186 binaryTemplateSpacings.period = uvar.spacingP;
1187 } else {
1188 binaryTemplateSpacings.period = sqrt( uvar.mismatchP / diagpp );
1189 }
1190
1191 /* metric elements for eccentric case not considered? */
1192
1193 UINT8 fCount = 0, aCount = 0, tCount = 0, pCount = 0;
1194 const UINT8 fSpacingNum = floor( uvar.fBand / binaryTemplateSpacings.fkdot[0] );
1195 const UINT8 aSpacingNum = floor( uvar.orbitAsiniSecBand / binaryTemplateSpacings.asini );
1196 const UINT8 tSpacingNum = floor( uvar.orbitTimeAscBand / XLALGPSGetREAL8( &binaryTemplateSpacings.tp ) );
1197 const UINT8 pSpacingNum = floor( ( config.orbitPSecMax - config.orbitPSecMin ) / binaryTemplateSpacings.period );
1198
1199 /* Initialize output arrays */
1200 REAL8Vector *ccStatVector = NULL;
1201 REAL8Vector *evSquaredVector = NULL;
1202 REAL8Vector *numeEquivAve = NULL;
1203 REAL8Vector *numeEquivCirc = NULL;
1204 XLAL_CHECK( ( ccStatVector = XLALCreateREAL8Vector( fSpacingNum + 1 ) ) != NULL, XLAL_EFUNC );
1205 XLAL_CHECK( ( evSquaredVector = XLALCreateREAL8Vector( fSpacingNum + 1 ) ) != NULL, XLAL_EFUNC );
1206 XLAL_CHECK( ( numeEquivAve = XLALCreateREAL8Vector( fSpacingNum + 1 ) ) != NULL, XLAL_EFUNC );
1207 XLAL_CHECK( ( numeEquivCirc = XLALCreateREAL8Vector( fSpacingNum + 1 ) ) != NULL, XLAL_EFUNC );
1208
1209 /*reset minbinaryOrbitParams to shift the first point a factor so as to make the center of all seaching points centers at the center of searching band*/
1210 minBinaryTemplate.fkdot[0] = uvar.fStart + 0.5 * ( uvar.fBand - fSpacingNum * binaryTemplateSpacings.fkdot[0] );
1211 minBinaryTemplate.asini = uvar.orbitAsiniSec + 0.5 * ( uvar.orbitAsiniSecBand - aSpacingNum * binaryTemplateSpacings.asini );
1212 XLALGPSSetREAL8( &minBinaryTemplate.tp, uvar.orbitTimeAsc + 0.5 * ( uvar.orbitTimeAscBand - tSpacingNum * XLALGPSGetREAL8( &binaryTemplateSpacings.tp ) ) );
1213 minBinaryTemplate.period = config.orbitPSecMin + 0.5 * ( config.orbitPSecMax - config.orbitPSecMin - pSpacingNum * binaryTemplateSpacings.period );
1214 /*also reset dopplerpos orbital parameters and frequency*/
1215 dopplerpos.fkdot[0] = minBinaryTemplate.fkdot[0];
1216 dopplerpos.asini = minBinaryTemplate.asini;
1217 dopplerpos.tp = minBinaryTemplate.tp;
1218 dopplerpos.period = minBinaryTemplate.period;
1219 if ( config.dPorbdTascShear != 0 ) {
1220 dopplerpos.period +=
1221 ( XLALGPSGetREAL8( &dopplerpos.tp )
1222 - config.orbitTimeAscCenterShifted )
1223 * config.dPorbdTascShear;
1224 }
1225
1226 /* BEGIN section resampled */
1227
1228 int numpoints = 0;
1229 int numorb = 0;
1230 UINT4 numSamplesFFT = 0;
1231 if ( uvar.resamp == TRUE ) {
1232 // Resampled loop
1233 XLALDestroyMultiSFTVector( inputSFTs );
1234//returns error code if exists
1235 if ( ( resampForLoopCrossCorr( dopplerpos, dopplerShiftFlag, binaryTemplateSpacings, minBinaryTemplate, maxBinaryTemplate, fCount, aCount, tCount, pCount, fSpacingNum, aSpacingNum, tSpacingNum, pSpacingNum, uvar, resampMultiWeights, &numSamplesFFT, ccStatVector, numeEquivAve, numeEquivCirc, evSquaredVector, estSens, resampGammaAve, resampMultiPairs, thisCandidate, ccToplist, resampTshort, &config ) != XLAL_SUCCESS ) ) {
1236 LogPrintf( LOG_CRITICAL, "%s: resampForLoopCrossCorr() failed with errno=%d\n", __func__, xlalErrno );
1238 }
1240 } else {
1241 // Regular loop
1242 COMPLEX8Vector *expSignalPhases = NULL;
1243 if ( ( expSignalPhases = XLALCreateCOMPLEX8Vector( numSFTs ) ) == NULL ) {
1244 LogPrintf( LOG_CRITICAL, "%s: XLALCreateREAL8Vector() failed with errno=%d\n", __func__, xlalErrno );
1246 }
1247 if ( ( demodLoopCrossCorr( multiBinaryTimes, multiSSBTimes, dopplerpos, dopplerShiftFlag, binaryTemplateSpacings, minBinaryTemplate, maxBinaryTemplate, fCount, aCount, tCount, pCount, fSpacingNum, aSpacingNum, tSpacingNum, pSpacingNum, shiftedFreqs, lowestBins, expSignalPhases, sincList, uvar, sftIndices, inputSFTs, badBins, Tsft, multiWeights, ccStat, evSquared, estSens, GammaAve, sftPairs, thisCandidate, ccToplist, ndim, dimf, dima, dimT, dimP, g_ij, &numpoints, &numorb, &config ) != XLAL_SUCCESS ) ) {
1248 LogPrintf( LOG_CRITICAL, "%s: demodLoopCrossCorr() failed with errno=%d\n", __func__, xlalErrno );
1250 }
1251
1252 XLALDestroyMultiSFTVector( inputSFTs );
1253 XLALDestroyCOMPLEX8Vector( expSignalPhases );
1254 }
1255 /* Destroy here, to be tidy and because big toplists writes are intensive */
1256 XLALDestroyREAL8Vector( ccStatVector );
1257 XLALDestroyREAL8Vector( evSquaredVector );
1258 XLALDestroyREAL8Vector( numeEquivAve );
1259 XLALDestroyREAL8Vector( numeEquivCirc );
1260 XLALDestroyUINT4Vector( lowestBins );
1261 XLALDestroyREAL8Vector( shiftedFreqs );
1263 XLALDestroyMultiSSBtimes( multiBinaryTimes );
1264 XLALDestroyMultiSSBtimes( multiSSBTimes );
1265 XLALDestroyREAL8Vector( GammaAve );
1266 XLALDestroyREAL8Vector( resampGammaAve );
1267 XLALDestroyMultiNoiseWeights( resampMultiWeights );
1268 XLALDestroyMultiNoiseWeights( multiWeights );
1269
1270 /* END section resampled */
1271
1272 /* write candidates to file */
1273 sort_crossCorrBinary_toplist( ccToplist );
1274 /* add error checking */
1275
1276 final_write_crossCorrBinary_toplist_to_file( ccToplist, uvar.toplistFilename, &checksum );
1277
1278 REAL8 h0Sens = sqrt( ( 10 / sqrt( estSens ) ) ); /*for a SNR=10 signal, the h0 we can detect*/
1279
1280 XLALGPSTimeNow( &computingEndGPSTime ); /*record the rough end time*/
1281 UINT4 computingTime = computingEndGPSTime.gpsSeconds - computingStartGPSTime.gpsSeconds;
1282 /* make a meta-data file*/
1283 if ( XLALUserVarWasSet( &uvar.logFilename ) ) {
1284 CHAR *CMDInputStr = XLALUserVarGetLog( UVAR_LOGFMT_CFGFILE );
1285 if ( ( fp = fopen( uvar.logFilename, "w" ) ) == NULL ) {
1286 LogPrintf( LOG_CRITICAL, "Can't write in logfile" );
1288 }
1289 fprintf( fp, "[UserInput]\n\n" );
1290 fprintf( fp, "%s\n", CMDInputStr );
1291 fprintf( fp, "[CalculatedValues]\n\n" );
1292 if ( config.norb != 0 ) {
1293 fprintf( fp, "norb = %d\n", config.norb );
1294 fprintf( fp, "orbitTimeAscCenterShifted = %.9f\n", config.orbitTimeAscCenterShifted );
1295 }
1296 REAL8 g_lm, eps_n;
1297 for ( UINT4 l = 0; l < coordSys.dim; l++ ) {
1298 for ( UINT4 m = 0; m < coordSys.dim; m++ ) {
1299 if ( l == m ) {
1300 g_lm = gsl_matrix_get( g_ij, l, m );
1301 fprintf( fp, "g_%c%c = %.9"LAL_REAL8_FORMAT"\n", dimName->data[l], dimName->data[m], g_lm );
1302 }
1303 }
1304 }
1305 for ( UINT4 l = 0; l < coordSys.dim; l++ ) {
1306 for ( UINT4 m = 0; m < coordSys.dim; m++ ) {
1307 if ( l < m ) {
1308 g_lm = gsl_matrix_get( g_ij, l, m );
1309 fprintf( fp, "g_%c%c = %.9"LAL_REAL8_FORMAT"\n", dimName->data[l], dimName->data[m], g_lm );
1310 }
1311 }
1312 }
1313 for ( UINT4 n = 0; n < coordSys.dim; n++ ) {
1314 eps_n = gsl_vector_get( eps_i, n );
1315 fprintf( fp, "eps_%c = %.9"LAL_REAL8_FORMAT"\n", dimName->data[n], eps_n );
1316 }
1317 /* old metric for debugging */
1318 fprintf( fp, "old_diagff = %.9g\n", old_diagff );
1319 fprintf( fp, "old_diagaa = %.9g\n", old_diagaa );
1320 fprintf( fp, "old_diagTT = %.9g\n", old_diagTT );
1321 fprintf( fp, "old_diagpp = %.9g\n", old_diagpp );
1322 if ( uvar.useShearedPorb == TRUE ) {
1323 fprintf( fp, "unsheared_gTT = %.9"LAL_REAL8_FORMAT"\n", config.unshearedgTT );
1324 fprintf( fp, "unsheared_gTP = %.9"LAL_REAL8_FORMAT"\n", config.unshearedgTP );
1325 fprintf( fp, "dPorbdTascShear = %.9"LAL_REAL8_FORMAT"\n", config.dPorbdTascShear );
1326 }
1327 fprintf( fp, "orbitPSecMin = %.9"LAL_REAL8_FORMAT"\n", config.orbitPSecMin );
1328 fprintf( fp, "orbitPSecMax = %.9"LAL_REAL8_FORMAT"\n", config.orbitPSecMax );
1329
1330 if ( uvar.useLattice == TRUE ) {
1331 fprintf( fp, "TemplatenumTotal = %d\n", numpoints );
1332 fprintf( fp, "TemplatenumOrb = %d\n", numorb );
1333 } else {
1334 fprintf( fp, "FSpacing = %.9g\n", binaryTemplateSpacings.fkdot[0] );
1335 fprintf( fp, "ASpacing = %.9g\n", binaryTemplateSpacings.asini );
1336 fprintf( fp, "TSpacing = %.9g\n", XLALGPSGetREAL8( &binaryTemplateSpacings.tp ) );
1337 fprintf( fp, "PSpacing = %.9g\n", binaryTemplateSpacings.period );
1338 fprintf( fp, "TemplatenumF = %" LAL_UINT8_FORMAT "\n", ( fSpacingNum + 1 ) );
1339 fprintf( fp, "TemplatenumA = %" LAL_UINT8_FORMAT "\n", ( aSpacingNum + 1 ) );
1340 fprintf( fp, "TemplatenumT = %" LAL_UINT8_FORMAT "\n", ( tSpacingNum + 1 ) );
1341 fprintf( fp, "TemplatenumP = %" LAL_UINT8_FORMAT "\n", ( pSpacingNum + 1 ) );
1342 fprintf( fp, "TemplatenumTotal = %" LAL_UINT8_FORMAT "\n", ( fSpacingNum + 1 ) * ( aSpacingNum + 1 ) * ( tSpacingNum + 1 ) * ( pSpacingNum + 1 ) );
1343 }
1344 if ( numSamplesFFT > 0 ) {
1345 fprintf( fp, "numSamplesFFT = %" LAL_UINT4_FORMAT "\n", numSamplesFFT );
1346 }
1347 fprintf( fp, "Sens = %.9g\n", estSens ); /*(E[rho]/h0^2)^2*/
1348 fprintf( fp, "h0_min_SNR10 = %.9g\n", h0Sens ); /*for rho = 10 in our pipeline*/
1349 fprintf( fp, "weightedMutAve = %.9f\n", weightedMuTAve ); /*weighted average of mean SFT from each pair of SFT*/
1350 fprintf( fp, "jobStartTime = %" LAL_INT4_FORMAT "\n", computingStartGPSTime.gpsSeconds ); /*job start time in GPS-time*/
1351 fprintf( fp, "jobEndTime = %" LAL_INT4_FORMAT "\n", computingEndGPSTime.gpsSeconds ); /*job end time in GPS-time*/
1352 fprintf( fp, "computingTime = %" LAL_UINT4_FORMAT "\n", computingTime ); /*total time in sec*/
1353 fprintf( fp, "SFTnum = %" LAL_UINT4_FORMAT "\n", numSFTs ); /*total number of SFT*/
1354 if ( tShortIndices ) {
1355 fprintf( fp, "Tshortnum = %" LAL_UINT4_FORMAT "\n", tShortIndices->length ); /*total number of SFT*/
1356 }
1357 if ( sftPairs ) {
1358 fprintf( fp, "pairnum = %" LAL_UINT4_FORMAT "\n", sftPairs->length ); /*total number of pair of SFT*/
1359 }
1360 if ( tShortPairs ) {
1361 fprintf( fp, "resamppairnum = %" LAL_UINT4_FORMAT "\n", tShortPairs->length ); /*total number of pair of SFT*/
1362 }
1363 fprintf( fp, "Tsft = %.6g\n", Tsft ); /*SFT duration*/
1364 fprintf( fp, "Tshort = %.6g\n", resampTshort ); /* resampling tShort duration */
1365 if ( config.mismatchMaxP != 0.0 ) {
1366 fprintf( fp, "mismatchMaxP = %.9f\n", config.mismatchMaxP );
1367 }
1368 if ( config.mismatchMaxThreeD != 0.0 ) {
1369 fprintf( fp, "mismatchMax3D = %.9f\n", config.mismatchMaxThreeD );
1370 }
1371 fprintf( fp, "mismatchMax = %"LAL_REAL8_FORMAT"\n", uvar.mismatchMax );
1372 fprintf( fp, "\n[Version]\n\n" );
1373 fprintf( fp, "%s", VCSInfoString );
1374 fclose( fp );
1375 XLALFree( CMDInputStr );
1376 }
1377
1378 /* FIXME: Need to destroy badBins */
1379
1380 /* Destroy output structures */
1381
1382 XLALFree( VCSInfoString );
1383 XLALDestroySFTPairIndexList( tShortPairs );
1384 XLALDestroySFTIndexList( tShortIndices );
1385 XLALDestroySFTPairIndexList( sftPairs );
1386 XLALDestroySFTIndexList( sftIndices );
1387 XLALDestroyCHARVector( dimName );
1388 /* de-allocate memory for configuration variables */
1389 XLALDestroyConfigVars( &config );
1390
1391 /* de-allocate memory for user input variables */
1393
1394 /* free toplist memory */
1395 free_crossCorr_toplist( &ccToplist );
1396
1397 /* free metric and offset */
1398 gsl_matrix_free( g_ij );
1399 gsl_vector_free( eps_i );
1400
1401 /* check memory leaks if we forgot to de-allocate anything */
1403
1404 LogPrintf( LOG_CRITICAL, "End time\n" ); /*for debug convenience to record calculating time*/
1405
1406 return 0;
1407
1408} /* main */
1409
1410/* initialize and register user variables */
1412{
1413
1414 /* initialize with some defaults */
1415 uvar->maxLag = 0.0;
1416 uvar->inclAutoCorr = FALSE;
1417 uvar->fStart = 100.0;
1418 uvar->fBand = 0.1;
1419 /* uvar->fdotStart = 0.0; */
1420 /* uvar->fdotBand = 0.0; */
1421 uvar->alphaRad = 0.0;
1422 uvar->deltaRad = 0.0;
1423 uvar->refTime = 0.0;
1424 uvar->rngMedBlock = 50;
1425 uvar->numBins = 1;
1426 uvar->resamp = FALSE;
1427 /* Leave uvar->tShort uninitialized so can check in main */
1428
1429 /* zero binary orbital parameters means not a binary */
1430 uvar->orbitAsiniSec = 0.0;
1431 uvar->orbitAsiniSecBand = 0.0;
1432 uvar->orbitPSec = 0.0;
1433 uvar->orbitPSecBand = 0.0;
1434 uvar->orbitTimeAsc = 0;
1435 uvar->orbitTimeAscBand = 0;
1436
1437 /* Default radius for elliptical boundary in Tasc-Porb */
1438 uvar->orbitTPEllipseRadius = 3.3;
1439
1440 /*default mismatch values */
1441 /* set to 0.1 by default -- for no real reason */
1442 /* make 0.1 a macro? */
1443 uvar->mismatchF = 0.1;
1444 uvar->mismatchA = 0.1;
1445 uvar->mismatchT = 0.1;
1446 uvar->mismatchP = 0.1;
1447
1448 uvar->ephemEarth = XLALStringDuplicate( "earth00-40-DE405.dat.gz" );
1449 uvar->ephemSun = XLALStringDuplicate( "sun00-40-DE405.dat.gz" );
1450
1451 uvar->sftLocation = XLALCalloc( 1, MAXFILENAMELENGTH + 1 );
1452
1453 /* initialize number of candidates in toplist -- default is just to return the single best candidate */
1454 uvar->numCand = 1;
1455 uvar->toplistFilename = XLALStringDuplicate( "toplist_crosscorr.dat" );
1456
1457 /* initialize number of Dirichlet terms for resampling sinc interpolation */
1458 /* Higher values reduce the frequency band wings for FFT,
1459 * at cost of higher time to barycenter initially */
1460 /* Specifically, model:
1461 * c_barycenter = C_B * Dterms,
1462 * c_fft = C_F * (1 + 2/(2 Dterms +1 )),
1463 * minimum of (c_barycenter+c_fft) at
1464 * Dterms = sqrt(C_F/C_B) - 1/2,
1465 * therefore if c_barycenter(128) approx c_fft(128),
1466 * C_F/C_B approx 127.0, so
1467 * Dterms = 10.7 is optimal. 8 is closer than 16.
1468 * This is checked empirically on a laptop. However,
1469 * the optimization is very shallow: 32 is also fine.
1470 */
1471 uvar->Dterms = 8;
1472 /* override default value in XLALFstatCheckSFTLengthMismatch(), which is 0.05 */
1473 /* Note that per Whelan et al PRD _91_, 102005 (2015) the starting point for CrossCorr searches is 1/17 ~= 0.059 */
1474 uvar->allowedMismatchFromSFTLength = 0.10;
1475
1476 /* initialize overall principles */
1477 uvar->inclSameDetector = TRUE;
1478 uvar->treatWarningsAsErrors = TRUE;
1479 uvar->testShortFunctions = FALSE;
1480 uvar->testResampNoTShort = FALSE;
1481
1482 /* lattice choices */
1483 uvar->useLattice = FALSE;
1484 uvar->latticeType = TILING_LATTICE_ANSTAR;
1485
1486 /* sheared period coordinate */
1487 uvar->useShearedPorb = FALSE;
1488 uvar->unresolvedPorbMismatch = 0.0;
1489 uvar->reallocatePorbMismatch = FALSE;
1490
1491 /* register user-variables */
1492 XLALRegisterUvarMember( startTime, INT4, 0, REQUIRED, "Desired start time of analysis in GPS seconds (SFT timestamps must be >= this)" );
1493 XLALRegisterUvarMember( endTime, INT4, 0, REQUIRED, "Desired end time of analysis in GPS seconds (SFT timestamps must be < this)" );
1494 XLALRegisterUvarMember( maxLag, REAL8, 0, OPTIONAL, "Maximum lag time in seconds between SFTs in correlation" );
1495 XLALRegisterUvarMember( inclAutoCorr, BOOLEAN, 0, OPTIONAL, "Include auto-correlation terms (an SFT with itself)" );
1496 XLALRegisterUvarMember( fStart, REAL8, 0, OPTIONAL, "Start frequency in Hz" );
1497 XLALRegisterUvarMember( fBand, REAL8, 0, OPTIONAL, "Frequency band to search over in Hz " );
1498 /* XLALRegisterUvarMember( fdotStart, REAL8, 0, OPTIONAL, "Start value of spindown in Hz/s"); */
1499 /* XLALRegisterUvarMember( fdotBand, REAL8, 0, OPTIONAL, "Band for spindown values in Hz/s"); */
1500 XLALRegisterUvarMember( alphaRad, REAL8, 0, OPTIONAL, "Right ascension for directed search (radians)" );
1501 XLALRegisterUvarMember( deltaRad, REAL8, 0, OPTIONAL, "Declination for directed search (radians)" );
1502 XLALRegisterUvarMember( refTime, REAL8, 0, OPTIONAL, "SSB reference time for pulsar-parameters [Default: midPoint]" );
1503 XLALRegisterUvarMember( orbitAsiniSec, REAL8, 0, OPTIONAL, "Start of search band for projected semimajor axis (seconds) [0 means not a binary]" );
1504 XLALRegisterUvarMember( orbitAsiniSecBand, REAL8, 0, OPTIONAL, "Width of search band for projected semimajor axis (seconds)" );
1505 XLALRegisterUvarMember( orbitPSec, REAL8, 0, OPTIONAL, "Binary orbital period (seconds) [0 means not a binary]" );
1506 XLALRegisterUvarMember( orbitPSecBand, REAL8, 0, OPTIONAL, "Band for binary orbital period (seconds) " );
1507 XLALRegisterUvarMember( orbitTimeAsc, REAL8, 0, OPTIONAL, "Start of orbital time-of-ascension band in GPS seconds" );
1508 XLALRegisterUvarMember( orbitTimeAscBand, REAL8, 0, OPTIONAL, "Width of orbital time-of-ascension band (seconds)" );
1509 XLALRegisterUvarMember( ephemEarth, STRING, 0, OPTIONAL, "Earth ephemeris file to use" );
1510 XLALRegisterUvarMember( ephemSun, STRING, 0, OPTIONAL, "Sun ephemeris file to use" );
1511 XLALRegisterUvarMember( sftLocation, STRING, 0, REQUIRED, "Filename pattern for locating SFT data. Possibilities are:\n"
1512 " - '<SFT file>;<SFT file>;...', where <SFT file> may contain wildcards\n - 'list:<file containing list of SFT files>'" );
1513 XLALRegisterUvarMember( rngMedBlock, INT4, 0, OPTIONAL, "Running median block size for PSD estimation" );
1514 XLALRegisterUvarMember( numBins, INT4, 0, OPTIONAL, "Number of frequency bins to include in calculation" );
1515 XLALRegisterUvarMember( mismatchF, REAL8, 0, OPTIONAL, "Desired mismatch for frequency spacing" );
1516 XLALRegisterUvarMember( mismatchA, REAL8, 0, OPTIONAL, "Desired mismatch for asini spacing" );
1517 XLALRegisterUvarMember( mismatchT, REAL8, 0, OPTIONAL, "Desired mismatch for periapse passage time spacing" );
1518 XLALRegisterUvarMember( mismatchP, REAL8, 0, OPTIONAL, "Desired mismatch for period spacing" );
1519 XLALRegisterUvarMember( spacingF, REAL8, 0, OPTIONAL, "Desired frequency spacing" );
1520 XLALRegisterUvarMember( spacingA, REAL8, 0, OPTIONAL, "Desired asini spacing" );
1521 XLALRegisterUvarMember( spacingT, REAL8, 0, OPTIONAL, "Desired periapse passage time spacing" );
1522 XLALRegisterUvarMember( spacingP, REAL8, 0, OPTIONAL, "Desired period spacing" );
1523 XLALRegisterUvarMember( numCand, INT4, 0, OPTIONAL, "Number of candidates to keep in toplist" );
1524 XLALRegisterUvarMember( linesToCleanFilenames, STRING, 0, OPTIONAL, "Comma-separated list of line files" );
1525 XLALRegisterUvarMember( pairListInputFilename, STRING, 0, OPTIONAL, "Name of file from which to read list of SFT pairs" );
1526 XLALRegisterUvarMember( pairListOutputFilename, STRING, 0, OPTIONAL, "Name of file to which to write list of SFT pairs" );
1527 XLALRegisterUvarMember( resampPairListOutputFilename, STRING, 0, OPTIONAL, "Name of file to which to write list of Tshort pairs" );
1528 XLALRegisterUvarMember( sftListOutputFilename, STRING, 0, OPTIONAL, "Name of file to which to write list of SFTs (for sanity checks)" );
1529 XLALRegisterUvarMember( tShortListOutputFilename, STRING, 0, OPTIONAL, "Name of file to which to write list of Tshorts (for sanity checks)" );
1530 XLALRegisterUvarMember( sftListInputFilename, STRING, 0, OPTIONAL, "Name of file to which to read in list of SFTs (for sanity checks)" );
1531 XLALRegisterUvarMember( gammaAveOutputFilename, STRING, 0, OPTIONAL, "Name of file to which to write aa+bb weights (for e.g., false alarm estimation)" );
1532 XLALRegisterUvarMember( resampGammaAveOutputFilename, STRING, 0, OPTIONAL, "Name of file to which to write aa+bb weights for Tshort pairs (for e.g., false alarm estimation)" );
1533 XLALRegisterUvarMember( gammaCircOutputFilename, STRING, 0, OPTIONAL, "Name of file to which to write ab-ba weights (for e.g., systematic error)" );
1534 XLALRegisterUvarMember( resampGammaCircOutputFilename, STRING, 0, OPTIONAL, "Name of file to which to write ab-ba weights for Tshort pairs (for e.g., systematic error)" );
1535 XLALRegisterUvarMember( toplistFilename, STRING, 0, OPTIONAL, "Output filename containing candidates in toplist" );
1536 XLALRegisterUvarMember( logFilename, STRING, 0, OPTIONAL, "Output a meta-data file for the search" );
1537 XLALRegisterUvarMember( resamp, BOOLEAN, 0, OPTIONAL, "Use resampling" );
1538 XLALRegisterUvarMember( tShort, REAL8, 0, OPTIONAL, "Resampling tShort for time series subdivisions pre-FFT" );
1539 XLALRegisterUvarMember( testShortFunctions, BOOLEAN, 0, OPTIONAL, "Use alternative functions for resampMultiPairs with tShort" );
1540 XLALRegisterUvarMember( testResampNoTShort, BOOLEAN, 0, OPTIONAL, "Use resampling without tShort (for e.g., comparison in gapless Gaussian data)" );
1541 XLALRegisterUvarMember( alignTShorts, BOOLEAN, 0, OPTIONAL, "Make sure tShort segments from different detectors are aligned" );
1542 XLALRegisterUvarMember( accurateResampMetric, BOOLEAN, 0, OPTIONAL, "Use more accurate calculation of metric for resampling" );
1543 XLALRegisterUvarMember( Dterms, INT4, 0, OPTIONAL, "Number of Dirichlet terms for resampling sinc interpolation" );
1544 XLALRegisterUvarMember( allowedMismatchFromSFTLength, REAL8, 0, OPTIONAL, "override default value in XLALFstatCheckSFTLengthMismatch() (only relevant for resamp)" );
1545 XLALRegisterUvarMember( inclSameDetector, BOOLEAN, 0, OPTIONAL, "Cross-correlate a detector with itself at a different time (if inclAutoCorr, then also same time)" );
1546 XLALRegisterUvarMember( treatWarningsAsErrors, BOOLEAN, 0, OPTIONAL, "Abort program if any warnings arise (for e.g., zero-maxLag radiometer mode)" );
1547 XLALRegisterUvarMember( injectionSources, STRINGVector, 0, OPTIONAL, "CSV file list containing sources to inject or '{Alpha=0;Delta=0;...}'" );
1548 XLALRegisterUvarMember( useLattice, BOOLEAN, 0, OPTIONAL, "Use latticeTiling for template placement" );
1549 XLALRegisterUvarMember( useShearedPorb, BOOLEAN, 0, OPTIONAL, "Use sheared period coordinate for template placement" );
1550 XLALRegisterUvarMember( unresolvedPorbMismatch, REAL8, 0, OPTIONAL, "If maximum mismatch in period direction is less than this, only one point compensate in overall mismatch" );
1551 XLALRegisterUvarMember( reallocatePorbMismatch, BOOLEAN, 0, OPTIONAL, "Compensate for unresolved period with actual mismatch in that direction. (Otherwise use mismatch threshold, which is more conservative.)" );
1552 XLALRegisterUvarAuxDataMember( latticeType, UserEnum, &TilingLatticeChoices, 0, OPTIONAL, "Type of lattice used for template placement" );
1553 XLALRegisterUvarMember( mismatchMax, REAL8, 0, OPTIONAL, "maximum mismatch to use for the lattice " );
1554 XLALRegisterUvarMember( orbitPSecCenter, REAL8, 0, OPTIONAL, " Center of prior ellipse for binary orbital period (seconds) " );
1555 XLALRegisterUvarMember( orbitPSecSigma, REAL8, 0, OPTIONAL, "One-sigma semiaxis for binary orbital period (seconds) " );
1556 XLALRegisterUvarMember( orbitTimeAscCenter, REAL8, 0, OPTIONAL, "Center of prior ellipse for orbital time-of-ascension in GPS seconds" );
1557 XLALRegisterUvarMember( orbitTimeAscSigma, REAL8, 0, OPTIONAL, "One-sigma semiaxis for orbital time of ascension (seconds)" );
1558 XLALRegisterUvarMember( orbitTPEllipseRadius, REAL8, 0, OPTIONAL, "Radius in sigma for Tasc-Porb search ellipse" );
1559
1560 XLALRegisterUvarMember( LatticeOutputFilename, STRING, 0, OPTIONAL, "Name of file to which to write lattice" );
1561
1562 if ( xlalErrno ) {
1563 XLALPrintError( "%s: user variable initialization failed with errno = %d.\n", __func__, xlalErrno );
1565 }
1566
1567 return XLAL_SUCCESS;
1568}
1569
1570/* initialize and register user variables */
1572{
1573
1574 static SFTConstraints constraints;
1575 LIGOTimeGPS startTime, endTime;
1576
1577 /* set sft catalog constraints */
1578 constraints.detector = NULL;
1579 constraints.timestamps = NULL;
1580 constraints.minStartTime = &startTime;
1581 constraints.maxStartTime = &endTime;
1582 XLALGPSSet( constraints.minStartTime, uvar->startTime, 0 );
1583 XLALGPSSet( constraints.maxStartTime, uvar->endTime, 0 );
1584
1585 if ( XLALUserVarWasSet( &( uvar->refTime ) ) ) {
1586 config->refTime = uvar->refTime;
1587 } else {
1588 config->refTime = uvar->startTime + 0.5 * ( ( REAL8 )( uvar->endTime - uvar->startTime ) );
1589 }
1590
1591 /* This check doesn't seem to work, since XLALGPSSet doesn't set its
1592 first argument.
1593
1594 if ( (constraints.minStartTime == NULL)&& (constraints.maxStartTime == NULL) ) {
1595 LogPrintf ( LOG_CRITICAL, "%s: XLALGPSSet() failed with errno=%d\n", __func__, xlalErrno );
1596 XLAL_ERROR( XLAL_EFUNC );
1597 }
1598
1599 */
1600
1601 /* get catalog of SFTs */
1602 if ( ( config->catalog = XLALSFTdataFind( uvar->sftLocation, &constraints ) ) == NULL ) {
1603 LogPrintf( LOG_CRITICAL, "%s: XLALSFTdataFind() failed with errno=%d\n", __func__, xlalErrno );
1605 }
1606
1607 /* initialize ephemeris data */
1608 XLAL_CHECK( ( config->edat = XLALInitBarycenter( uvar->ephemEarth, uvar->ephemSun ) ) != NULL, XLAL_EFUNC );
1609
1610 /* parse comma-separated list of lines files */
1611 config->lineFiles = NULL;
1612
1613 if ( XLALUserVarWasSet( &uvar->linesToCleanFilenames ) ) {
1614 CHAR *tmpstring = NULL;
1615 XLAL_CHECK( ( tmpstring = XLALStringDuplicate( uvar->linesToCleanFilenames ) ) != NULL, XLAL_EFUNC );
1616
1617 UINT4 numfiles = pcc_count_csv( tmpstring );
1618
1619 LALFree( tmpstring );
1620 XLAL_CHECK( ( tmpstring = XLALStringDuplicate( uvar->linesToCleanFilenames ) ) != NULL, XLAL_EFUNC );
1621
1622 for ( UINT4 i = 0 ; i < numfiles ; i++ ) {
1623 CHAR *pcc_tmpfile = NULL;
1624 XLAL_CHECK( ( pcc_tmpfile = XLALStringToken( &tmpstring, ",", 0 ) ) != NULL, XLAL_EFUNC );
1625 XLAL_CHECK( ( config->lineFiles = XLALAppendString2Vector( config->lineFiles, pcc_tmpfile ) ) != NULL, XLAL_EFUNC );
1626
1627 }
1628 }
1629
1630 if ( XLALUserVarWasSet( &uvar->orbitPSecCenter ) || XLALUserVarWasSet( &uvar->orbitPSecSigma ) || XLALUserVarWasSet( &uvar->orbitTimeAscCenter ) || XLALUserVarWasSet( &uvar->orbitTimeAscSigma ) ) {
1631 /* Consistency checks */
1632 if ( !( XLALUserVarWasSet( &uvar->orbitPSecCenter ) ) || !( XLALUserVarWasSet( &uvar->orbitPSecSigma ) ) || !( XLALUserVarWasSet( &uvar->orbitTimeAscCenter ) ) || !( XLALUserVarWasSet( &uvar->orbitTimeAscSigma ) ) ) {
1633 printf( "Error! Need to set all or none of --orbitPSecCenter --orbitPSecSigma --orbitTimeAscCenter --orbitTimeAscSigma\n" );
1635 }
1636 /* If these parameters have been set, it's because we're using the sheared perior coordinate, or the elliptical boundaries, or both */
1637 if ( uvar->useShearedPorb ) {
1638 if ( ( uvar->orbitPSec != 0.0 ) ) {
1639 if ( XLALUserVarWasSet( &uvar->orbitTPEllipseRadius ) ) {
1640 /* If we get here, both --orbitTPEllipseRadius and --orbitPSec were set, which was probably a mistake, but we ignore --orbitPSec */
1641 config->useTPEllipse = TRUE;
1642 printf( "Warning! --orbitPSec not expected with elliptical boundaries; ignored\n" );
1643 if ( uvar->treatWarningsAsErrors ) {
1644 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
1646 }
1647 }
1648 /* If we get here, --useShearedPorb and --orbitPSec were set, so we're doing a search with constant boundaries in the sheared period coordinate and config->useTPEllipse remains false */
1649 } else {
1650 config->useTPEllipse = TRUE;
1651 if ( ( uvar->orbitPSecBand != 0.0 ) ) {
1652 printf( "Warning! --orbitPSecBand not expected with elliptical boundaries\n; ignored\n" );
1653 if ( uvar->treatWarningsAsErrors ) {
1654 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
1656 }
1657 }
1658 }
1659 } else {
1660 /* If we get here, we specified the parameters of the elliptical boundary but are not using the sheared period coordinate, so we go with the default value for --orbitTPEllipseRadius if it wasn't set on the command line */
1661 if ( ( uvar->orbitPSec != 0.0 ) ) {
1662 printf( "Warning! --orbitPSec not expected with elliptical boundaries; ignored\n" );
1663 if ( uvar->treatWarningsAsErrors ) {
1664 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
1666 }
1667 }
1668 if ( ( uvar->orbitPSecBand != 0.0 ) ) {
1669 printf( "Warning! --orbitPSecBand not expected with elliptical boundaries\n; ignored\n" );
1670 if ( uvar->treatWarningsAsErrors ) {
1671 printf( "Error! (--treatWarningsAsErrors flag is true).\n" );
1673 }
1674 }
1675 if ( uvar->useLattice == FALSE ) {
1676 printf( "Error! Elliptical boundary only works with LatticeTiling\n" );
1678 }
1679 config->useTPEllipse = TRUE;
1680 }
1681 if ( uvar->resamp == TRUE && config->useTPEllipse == TRUE ) {
1682 printf( "Error! Elliptical boundary not yet implemented with resampling\n" );
1684 }
1685 /* End consistency checks */
1686 /* Compute number of orbits to shift prior ellipse */
1687 config->norb = ( int ) round( ( uvar->orbitTimeAsc
1688 + 0.5 * uvar->orbitTimeAscBand
1689 - uvar->orbitTimeAscCenter )
1690 / uvar->orbitPSecCenter );
1691 config->dPorbdTascShear =
1692 ( config->norb
1693 / ( SQR( config->norb )
1694 + SQR( ( uvar->orbitTimeAscSigma / uvar->orbitPSecSigma ) ) ) );
1695 } else {
1696 if ( uvar->useShearedPorb == TRUE ) {
1697 printf( "Error! Sheared period requires values for --orbitPSecCenter --orbitPSecSigma --orbitTimeAscCenter --orbitTimeAscSigma\n" );
1699 }
1700 config->useTPEllipse = FALSE;
1701 config->norb = 0; /* undefined since we don't know the epoch of the uncorrelated Tasc and Porb estimates */
1702 config->dPorbdTascShear = 0;
1703 }
1704 if ( config->useTPEllipse == TRUE ) {
1705 config->orbitPSecMin = uvar->orbitPSecCenter - uvar->orbitTPEllipseRadius * uvar->orbitPSecSigma;
1706 config->orbitPSecMax = uvar->orbitPSecCenter + uvar->orbitTPEllipseRadius * uvar->orbitPSecSigma;
1707 } else {
1708 config->orbitPSecMin = uvar->orbitPSec;
1709 config->orbitPSecMax = uvar->orbitPSec + uvar->orbitPSecBand;
1710 }
1711 config->orbitTimeAscCenterShifted = uvar->orbitTimeAscCenter + config->norb * uvar->orbitPSecCenter;
1712
1713 return XLAL_SUCCESS;
1714
1715}
1716/* XLALInitializeConfigVars() */
1717
1718/* deallocate memory associated with config variables */
1720{
1721 XLALDestroySFTCatalog( config->catalog );
1722 XLALDestroyEphemerisData( config->edat );
1724 return XLAL_SUCCESS;
1725}
1726/* XLALDestroyConfigVars() */
1727
1728/* getting the next template */
1729/** FIXME: spacings and min, max values of binary parameters are not used yet */
1730
1731int GetNextCrossCorrTemplate( BOOLEAN *binaryParamsFlag, BOOLEAN *firstPoint, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *binaryTemplateSpacings, PulsarDopplerParams *minBinaryTemplate, PulsarDopplerParams *maxBinaryTemplate, UINT8 *fCount, UINT8 *aCount, UINT8 *tCount, UINT8 *pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, ConfigVariables *config )
1732{
1733
1734 /* basic sanity checks */
1735 if ( binaryTemplateSpacings == NULL ) {
1736 return -1;
1737 }
1738
1739 if ( minBinaryTemplate == NULL ) {
1740 return -1;
1741 }
1742
1743 if ( maxBinaryTemplate == NULL ) {
1744 return -1;
1745 }
1746
1747 /* check spacings not negative */
1748
1749 if ( *fCount < fSpacingNum ) { /*loop over f at first*/
1750 dopplerpos->fkdot[0] = minBinaryTemplate->fkdot[0] + ( *fCount + 1 ) * binaryTemplateSpacings->fkdot[0];
1751 *binaryParamsFlag = FALSE;
1752 *fCount += 1;
1753 return 0;
1754 } else {
1755 if ( *aCount < aSpacingNum ) { /*after looping all f, initialize f and loop over a_p*/
1756 dopplerpos->asini = minBinaryTemplate->asini + ( *aCount + 1 ) * binaryTemplateSpacings->asini;
1757 dopplerpos->fkdot[0] = minBinaryTemplate->fkdot[0];
1758 *fCount = 0;
1759 *binaryParamsFlag = TRUE;
1760 *aCount += 1;
1761 return 0;
1762 } else {
1763 if ( *pCount < pSpacingNum ) { /*after looping the plane of f and a_p, initialize f, a_p and loop over P*/
1764 dopplerpos->period = minBinaryTemplate->period + ( *pCount + 1 ) * binaryTemplateSpacings->period;
1765 if ( config->dPorbdTascShear != 0 ) {
1766 dopplerpos->period +=
1767 ( XLALGPSGetREAL8( &dopplerpos->tp )
1768 - config->orbitTimeAscCenterShifted )
1769 * config->dPorbdTascShear;
1770 }
1771 dopplerpos->fkdot[0] = minBinaryTemplate->fkdot[0];
1772 *fCount = 0;
1773 dopplerpos->asini = minBinaryTemplate->asini;
1774 *aCount = 0;
1775 *binaryParamsFlag = TRUE;
1776 *pCount += 1;
1777 return 0;
1778 }
1779
1780 else {
1781 if ( *tCount < tSpacingNum ) { /*after looping f, a_p and P, initialize f, a_p and P, then loop over T*/
1782 REAL8 nextGPSTime = XLALGPSGetREAL8( &minBinaryTemplate->tp ) + ( *tCount + 1 ) * XLALGPSGetREAL8( &binaryTemplateSpacings->tp );
1783 XLALGPSSetREAL8( &dopplerpos->tp, nextGPSTime );
1784 dopplerpos->fkdot[0] = minBinaryTemplate->fkdot[0];
1785 *fCount = 0;
1786 dopplerpos->asini = minBinaryTemplate->asini;
1787 *aCount = 0;
1788 dopplerpos->period = minBinaryTemplate->period;
1789 if ( config->dPorbdTascShear != 0 ) {
1790 dopplerpos->period +=
1791 ( nextGPSTime - config->orbitTimeAscCenterShifted )
1792 * config->dPorbdTascShear;
1793 }
1794 *pCount = 0;
1795 *binaryParamsFlag = TRUE;
1796 *tCount += 1;
1797 return 0;
1798 }
1799
1800 else {
1801 if ( *firstPoint == TRUE ) { /*go back to search at the beginning point in parameter space*/
1802 dopplerpos->fkdot[0] = minBinaryTemplate->fkdot[0];
1803 dopplerpos->asini = minBinaryTemplate->asini;
1804 dopplerpos->period = minBinaryTemplate->period;
1805 dopplerpos->tp = minBinaryTemplate->tp;
1806 if ( config->dPorbdTascShear != 0 ) {
1807 dopplerpos->period +=
1808 ( XLALGPSGetREAL8( &dopplerpos->tp )
1809 - config->orbitTimeAscCenterShifted )
1810 * config->dPorbdTascShear;
1811 }
1812 *firstPoint = FALSE;
1813 *binaryParamsFlag = TRUE;
1814 return 0;
1815 } else {
1816 return 1;
1817 }
1818 }
1819 }
1820 }
1821 }
1822}
1823
1824/* Reorder the loop to prepare for resampling */
1825
1826/* int GetNextCrossCorrTemplateResamp(BOOLEAN *binaryParamsFlag, BOOLEAN *firstPoint, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *binaryTemplateSpacings, PulsarDopplerParams *minBinaryTemplate, PulsarDopplerParams *maxBinaryTemplate, UINT8 *fCount, UINT8 *aCount, UINT8 *tCount, UINT8 *pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum) */
1827/* { */
1828
1829/* /\* basic sanity checks *\/ */
1830/* if (binaryTemplateSpacings == NULL) */
1831/* return -1; */
1832
1833/* if (minBinaryTemplate == NULL) */
1834/* return -1; */
1835
1836/* if (maxBinaryTemplate == NULL) */
1837/* return -1; */
1838
1839/* /\* check spacings not negative *\/ */
1840
1841/* if ( *tCount < tSpacingNum) /\*loop over T at first*\/ */
1842/* { */
1843/* REAL8 nextGPSTime = XLALGPSGetREAL8(&minBinaryTemplate->tp) + (*tCount + 1) * XLALGPSGetREAL8(&binaryTemplateSpacings->tp); */
1844/* XLALGPSSetREAL8( &dopplerpos->tp, nextGPSTime); */
1845/* *binaryParamsFlag = TRUE; //Not very sure about this being True */
1846/* *tCount += 1; */
1847/* return 0; */
1848/* } */
1849/* else */
1850/* { */
1851/* if ( *aCount < aSpacingNum ) /\*after looping all T, initialize T and loop over a_p*\/ */
1852/* { */
1853/* dopplerpos->asini = minBinaryTemplate->asini + (*aCount + 1) * binaryTemplateSpacings->asini; */
1854/* dopplerpos->tp = minBinaryTemplate->tp; */
1855/* *tCount = 0; */
1856/* *binaryParamsFlag = TRUE; */
1857/* *aCount += 1; */
1858/* return 0; */
1859/* } */
1860/* else */
1861/* { */
1862/* if ( *pCount < pSpacingNum ) /\*after looping the plane of T and a_p, initialize T, a_p and loop over P*\/ */
1863/* { */
1864/* dopplerpos->period = minBinaryTemplate->period + (*pCount + 1) * binaryTemplateSpacings->period; */
1865/* dopplerpos->tp = minBinaryTemplate->tp; */
1866/* *tCount = 0; */
1867/* dopplerpos->asini = minBinaryTemplate->asini; */
1868/* *aCount = 0; */
1869/* *binaryParamsFlag = TRUE; */
1870/* *pCount += 1; */
1871/* return 0; */
1872/* } */
1873
1874/* else */
1875/* { */
1876/* if ( *fCount < fSpacingNum ) /\*after looping T, a_p and P, initialize T, a_p and P, then loop over f*\/ */
1877/* { */
1878/* dopplerpos->fkdot[0] = minBinaryTemplate->fkdot[0] + (*fCount + 1) * binaryTemplateSpacings->fkdot[0]; */
1879/* dopplerpos->tp = minBinaryTemplate->tp; */
1880/* *tCount = 0; */
1881/* dopplerpos->asini = minBinaryTemplate->asini; */
1882/* *aCount = 0; */
1883/* dopplerpos->period = minBinaryTemplate->period; */
1884/* *pCount = 0; */
1885/* *binaryParamsFlag = FALSE; //Not very sure about this being False */
1886/* *fCount += 1; */
1887/* return 0; */
1888/* } */
1889
1890/* else */
1891/* { */
1892/* if (*firstPoint == TRUE) /\*go back to search at the beginning point in parameter space*\/ */
1893/* { */
1894/* dopplerpos->fkdot[0] = minBinaryTemplate->fkdot[0]; */
1895/* dopplerpos->asini = minBinaryTemplate->asini; */
1896/* dopplerpos->period = minBinaryTemplate->period; */
1897/* dopplerpos->tp = minBinaryTemplate->tp; */
1898/* *firstPoint = FALSE; */
1899/* *binaryParamsFlag = TRUE; */
1900/* return 0; */
1901/* } */
1902/* else */
1903/* return 1; */
1904/* } */
1905/* } */
1906/* } */
1907/* } */
1908/* } */
1909
1910
1911int GetNextCrossCorrTemplateForResamp( BOOLEAN *binaryParamsFlag, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *binaryTemplateSpacings, PulsarDopplerParams *minBinaryTemplate, PulsarDopplerParams *maxBinaryTemplate, UINT8 *fCount, UINT8 *aCount, UINT8 *tCount, UINT8 *pCount, ConfigVariables *config )
1912{
1913 /* In the future, this could be replaced with a more efficient lattice
1914 * than this simple cubic */
1915
1916 /* basic sanity checks */
1917 if ( binaryTemplateSpacings == NULL ) {
1918 return -1;
1919 }
1920
1921 if ( minBinaryTemplate == NULL ) {
1922 return -1;
1923 }
1924
1925 if ( maxBinaryTemplate == NULL ) {
1926 return -1;
1927 }
1928
1929 /* check spacings not negative */
1930
1931 /* Always looping over F: this will be subsumed by resampling */
1932 *binaryParamsFlag = FALSE;
1933 dopplerpos->fkdot[0] = minBinaryTemplate->fkdot[0] + ( *fCount ) * binaryTemplateSpacings->fkdot[0];
1934 if ( *fCount == 0 ) {
1935 *binaryParamsFlag = TRUE;
1936 dopplerpos->asini = minBinaryTemplate->asini + ( *aCount ) * binaryTemplateSpacings->asini;
1937 if ( *aCount == 0 ) {
1938 dopplerpos->period = minBinaryTemplate->period + ( *pCount ) * binaryTemplateSpacings->period;
1939 if ( *pCount == 0 ) {
1940 REAL8 nextGPSTime = XLALGPSGetREAL8( &minBinaryTemplate->tp ) + ( *tCount ) * XLALGPSGetREAL8( &binaryTemplateSpacings->tp );
1941 XLALGPSSetREAL8( &dopplerpos->tp, nextGPSTime );
1942 }
1943 if ( config->dPorbdTascShear != 0 ) {
1944 dopplerpos->period +=
1945 ( XLALGPSGetREAL8( &dopplerpos->tp )
1946 - config->orbitTimeAscCenterShifted )
1947 * config->dPorbdTascShear;
1948 }
1949 }
1950 }
1951 return 0;
1952
1953} /* end GetNextCrossCorrTemplateForResamp */
1954
1955/* Copied from ppe_utils.c by Matt Pitkin */
1956
1957/**
1958 * \brief Counts the number of comma separated values in a string
1959 *
1960 * This function counts the number of comma separated values in a given input string.
1961 *
1962 * \param csvline [in] Any string
1963 *
1964 * \return The number of comma separated value in the input string
1965 */
1967{
1968 CHAR *inputstr = NULL;
1969 UINT4 count = 0;
1970
1971 inputstr = XLALStringDuplicate( csvline );
1972
1973 /* count number of commas */
1974 while ( 1 ) {
1975 if ( XLALStringToken( &inputstr, ",", 0 ) == NULL ) {
1976 XLAL_ERROR( XLAL_EFUNC, "Error... problem counting number of commas!" );
1977 }
1978
1979 if ( inputstr == NULL ) {
1980 break;
1981 }
1982
1983 count++;
1984 }
1985
1986 return count + 1;
1987}
1988
1989/** Convert a range of contaminated frequencies into a set of bins to zero out */
1990/* Returns the running number of zeroed bins */
1992(
1993 UINT4Vector *badBinData, /* Modified: running list of bad bins */
1994 INT4 binCount, /* Input: number of bins already in list */
1995 REAL8 flo, /* Input: Lower end of contaminated frequency range */
1996 REAL8 fhi, /* Input: Upper end of contaminated frequency range */
1997 REAL8 f0, /* Input: Base frequency of frequency series */
1998 REAL8 deltaF, /* Input: Frequency step of frequency series */
1999 UINT4 length /* Input: Size of frequency series */
2000)
2001{
2002
2003 /* printf ("veto %f to %f\n", flo, fhi); */
2004
2005 /* printf ("Series has %d bins starting at %f with %f spacing\n", length, f0, deltaF); */
2006 /* printf ("Last bin is %f\n", f0 + length * deltaF); */
2007
2008 INT4 newBinCount = binCount;
2009 INT4 firstBadBin = ( INT4 ) floor( ( flo - f0 ) / deltaF ); /*use floor to get the lowest contaminated bin*/
2010 /* printf ("firstBadBin = %d\n",firstBadBin); */
2011 if ( firstBadBin < 0 ) {
2012 firstBadBin = 0;
2013 }
2014 INT4 lastBadBin = ( INT4 ) ceil( ( fhi - f0 ) / deltaF ); /*use ceil to get the highest contaminated bin make sure to extend the boundary*/
2015 /* printf ("lastBadBin = %d\n",lastBadBin); */
2016 if ( lastBadBin >= ( INT4 ) length ) {
2017 lastBadBin = ( INT4 )( length - 1 );
2018 }
2019
2020 /* printf ("%d %d\n", firstBadBin, lastBadBin); */
2021
2022 for ( INT4 badBin = firstBadBin ; badBin <= lastBadBin ; badBin++ ) {
2023 /* printf ("%d %d %d\n", badBin, firstBadBin, lastBadBin); */
2024 if ( newBinCount > ( INT4 ) length ) {
2025 LogPrintf( LOG_CRITICAL, "%s: requested bin %d longer than series length %d\n", __func__, newBinCount, length );
2027 }
2028 UINT4 checkIfBinAppeared = 0;
2029 for ( INT4 checkExistBadBin = 0; checkExistBadBin < binCount; checkExistBadBin++ ) {
2030 if ( badBin < 0 ) {
2031 LogPrintf( LOG_CRITICAL, "badBin %d negative", badBin );
2033 }
2034 if ( badBinData->data[checkExistBadBin] == ( UINT4 ) badBin ) {
2035 checkIfBinAppeared++;
2036 }
2037 }
2038 if ( checkIfBinAppeared == 0 ) {
2039 badBinData->data[newBinCount] = badBin;
2040 newBinCount++;
2041 }
2042 }
2043
2044 return newBinCount;
2045
2046}
2047
2048/** Function to isolate the loop for demod */
2049int demodLoopCrossCorr( MultiSSBtimes *multiBinaryTimes, MultiSSBtimes *multiSSBTimes, PulsarDopplerParams dopplerpos, BOOLEAN dopplerShiftFlag, PulsarDopplerParams binaryTemplateSpacings, PulsarDopplerParams minBinaryTemplate, PulsarDopplerParams maxBinaryTemplate, UINT8 fCount, UINT8 aCount, UINT8 tCount, UINT8 pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, REAL8Vector *shiftedFreqs, UINT4Vector *lowestBins, COMPLEX8Vector *expSignalPhases, REAL8VectorSequence *sincList, UserInput_t uvar, SFTIndexList *sftIndices, MultiSFTVector *inputSFTs, MultiUINT4Vector *badBins, REAL8 Tsft, MultiNoiseWeights *multiWeights, REAL8 ccStat, REAL8 evSquared, REAL8 estSens, REAL8Vector *GammaAve, SFTPairIndexList *sftPairs, CrossCorrBinaryOutputEntry thisCandidate, toplist_t *ccToplist, int DEMODndim, int DEMODdimf, int DEMODdima, int DEMODdimT, int DEMODdimP, gsl_matrix *metric_ij, int *DEMODnumpoints, int *DEMODnumorb, ConfigVariables *config )
2050{
2051
2052 if ( uvar.useLattice == TRUE ) {
2053 FILE *LatticeFile = NULL;
2054 if ( uvar.LatticeOutputFilename != NULL ) { /* Write the list of pairs to a file, if a name was provided */
2055 if ( ( LatticeFile = fopen( uvar.LatticeOutputFilename, "w" ) ) == NULL ) {
2056 LogPrintf( LOG_CRITICAL, "Can't write in Lattice file \n" );
2058 }
2059 }
2060
2061 LatticeTiling *tiling = XLALCreateLatticeTiling( DEMODndim );
2062 XLALSetLatticeTilingConstantBound( tiling, DEMODdimT, uvar.orbitTimeAsc, uvar.orbitTimeAsc + uvar.orbitTimeAscBand );
2063
2064 REAL8 mismatchMax = uvar.mismatchMax;
2065 if ( uvar.unresolvedPorbMismatch > 0.0 ) {
2066 gsl_matrix *ginv_ij = gsl_matrix_alloc( DEMODndim, DEMODndim );
2067
2068 XLAL_CHECK( gsl_matrix_memcpy( ginv_ij, metric_ij ) == 0, XLAL_EFAILED );
2069 XLAL_CHECK( gsl_linalg_cholesky_decomp( ginv_ij ) == 0, XLAL_EFAILED );
2070 XLAL_CHECK( gsl_linalg_cholesky_invert( ginv_ij ) == 0, XLAL_EFAILED );
2071 REAL8 deltaP;
2072 if ( config->useTPEllipse == TRUE ) {
2073 deltaP = uvar.orbitTPEllipseRadius * uvar.orbitPSecSigma;
2074 /* printf('DeltaP = %g',deltaP) */
2075 if ( uvar.useShearedPorb ) {
2076 deltaP *= 1. / sqrt( 1. + SQR( config->norb * uvar.orbitPSecSigma / uvar.orbitTimeAscSigma ) );
2077 /* printf('DeltaPtilde = %g',deltaP) */
2078 }
2079 } else {
2080 deltaP = 0.5 * uvar.orbitPSecBand;
2081 }
2082 /* Adjust maximum mismatch in constant-P surface to account for finite width in P coordinate (Porb or sheared Ptilde) */
2083 config->mismatchMaxP = SQR( deltaP ) / gsl_matrix_get( ginv_ij, DEMODdimP, DEMODdimP );
2084 if ( config->mismatchMaxP < uvar.unresolvedPorbMismatch ) {
2085 if ( uvar.reallocatePorbMismatch ) {
2086 mismatchMax -= config->mismatchMaxP;
2087 } else {
2088 mismatchMax -= uvar.unresolvedPorbMismatch;
2089 }
2090 config->mismatchMaxThreeD = mismatchMax;
2091 if ( uvar.useShearedPorb ) {
2092 XLALSetLatticeTilingConstantBound( tiling, DEMODdimP, uvar.orbitPSecCenter, uvar.orbitPSecCenter );
2093 } else {
2094 XLALSetLatticeTilingConstantBound( tiling, DEMODdimP, uvar.orbitPSec + deltaP, uvar.orbitPSec + deltaP );
2095 }
2096
2097 /* The following check should be unneccesary since we check that uvar.unresolvedPorbMismatch <= uvar.mismatchMax */
2098 /* if (mismatchMax < 0) {
2099 printf("Error! Remaining mismatch after setting period is negative: %g\n", mismatchMax);
2100 XLAL_ERROR( XLAL_EFUNC );
2101 } */
2102 }
2103 gsl_matrix_free( ginv_ij );
2104 }
2105
2106 /* If we haven't adjusted the mismatch for an unresolved period, we need to set the usual boundaries for the period */
2107 if ( mismatchMax == uvar.mismatchMax ) {
2108 if ( config->useTPEllipse == TRUE ) {
2109 XLALSetLatticeTilingPorbEllipticalBound( tiling, DEMODdimT, DEMODdimP, uvar.orbitPSecCenter, uvar.orbitPSecSigma, uvar.orbitTimeAscCenter, uvar.orbitTimeAscSigma, config->norb, uvar.orbitTPEllipseRadius, uvar.useShearedPorb );
2110 } else {
2111 XLALSetLatticeTilingConstantBound( tiling, DEMODdimP, uvar.orbitPSec, uvar.orbitPSec + uvar.orbitPSecBand );
2112 }
2113 }
2114 XLALSetLatticeTilingConstantBound( tiling, DEMODdima, uvar.orbitAsiniSec, uvar.orbitAsiniSec + uvar.orbitAsiniSecBand );
2115
2116 XLALSetLatticeTilingConstantBound( tiling, DEMODdimf, uvar.fStart, uvar.fStart + uvar.fBand );
2117 int lattice = uvar.latticeType;
2118
2119 XLALSetTilingLatticeAndMetric( tiling, lattice, metric_ij, mismatchMax );
2120 LatticeTilingIterator *iterator = XLALCreateLatticeTilingIterator( tiling, DEMODndim );
2121
2122 gsl_vector *curr_point = gsl_vector_alloc( DEMODndim );
2123 gsl_vector *prev_point = gsl_vector_alloc( DEMODndim );
2124 curr_point->data[DEMODdimP] = 0.5 * ( config->orbitPSecMin + config->orbitPSecMax );
2125 if ( uvar.useShearedPorb ) {
2126 curr_point->data[DEMODdimP] -=
2127 ( curr_point->data[DEMODdimT] - config->orbitTimeAscCenterShifted )
2128 * config->dPorbdTascShear;
2129 }
2130 curr_point->data[DEMODdimT] = uvar.orbitTimeAsc + ( uvar.orbitTimeAscBand / 2.0 );
2131 curr_point->data[DEMODdima] = uvar.orbitAsiniSec + ( uvar.orbitAsiniSecBand / 2.0 );
2132 curr_point->data[DEMODdimf] = uvar.fStart + ( uvar.fBand / 2.0 );
2133 if ( LatticeFile != NULL ) {
2134 if ( uvar.useShearedPorb ) {
2135 fprintf( LatticeFile, "# TASC\tPTILDE\tASINI\tFREQ\n" );
2136 } else {
2137 fprintf( LatticeFile, "# TASC\tPORB\tASINI\tFREQ\n" );
2138 }
2139 fprintf( LatticeFile, "%f\t%f\t%f\t%f\n", curr_point->data[DEMODdimT], curr_point->data[DEMODdimP], curr_point->data[DEMODdima], curr_point->data[DEMODdimf] );
2140 }
2141 while ( XLALNextLatticeTilingPoint( iterator, curr_point ) > 0 ) {
2142 dopplerpos.fkdot[0] = curr_point->data[DEMODdimf];
2143 dopplerpos.asini = curr_point->data[DEMODdima];
2144 dopplerpos.period = curr_point->data[DEMODdimP];
2145 XLALGPSSetREAL8( &( dopplerpos.tp ), curr_point->data[DEMODdimT] );
2146 *DEMODnumpoints += 1;
2147 if ( uvar.useShearedPorb ) {
2148 dopplerpos.period +=
2149 ( curr_point->data[DEMODdimT] - config->orbitTimeAscCenterShifted )
2150 * config->dPorbdTascShear;
2151 }
2152
2153 if ( LatticeFile != NULL ) {
2154 fprintf( LatticeFile, "%f\t%f\t%f\t%f\n", curr_point->data[DEMODdimT], curr_point->data[DEMODdimP], curr_point->data[DEMODdima], curr_point->data[DEMODdimf] );
2155 }
2156 /* if counter is on first point, the orbital points haven't changed so make the dopplerShiftFlag = FALSE*/
2157 if ( *DEMODnumpoints == 1 ) {
2158 dopplerShiftFlag = TRUE;
2159 /* dopplerShiftFlag = FALSE; */
2160 /* prev_point->data[DEMODdimf] = curr_point->data[DEMODdimf]; */
2161 /* prev_point->data[DEMODdima] = curr_point->data[DEMODdima]; */
2162 /* prev_point->data[DEMODdimP] = curr_point->data[DEMODdimP]; */
2163 /* prev_point->data[DEMODdimT] = curr_point->data[DEMODdimT]; */
2164 } else if ( ( prev_point->data[DEMODdima] == curr_point->data[DEMODdima] )
2165 && ( prev_point->data[DEMODdimP] == curr_point->data[DEMODdimP] )
2166 && ( prev_point->data[DEMODdimT] == curr_point->data[DEMODdimT] ) ) {
2167 dopplerShiftFlag = FALSE;
2168 } else {
2169 dopplerShiftFlag = TRUE;
2170 }
2171
2172 /* if not on the first point, check that the previous orbital points are the same as the current points. If it is the same, the dopplerShiftFlag is false and we don't need additional doppler shifting */
2173 /** else if (prev_point->data[DEMODdima] == curr_point->data[DEMODdima] && prev_point->data[DEMODdimP] == curr_point->data[DEMODdimP] && prev_point->data[DEMODdimT] == curr_point->data[DEMODdimT]) **/
2174 /**{
2175 dopplerShiftFlag = FALSE;
2176 }**/
2177 /* if not on the first point, check that the previous orbital points are different current point. If it is the differennt, the dopplerShiftFlag is true and we need additional doppler shifting */
2178 /** else if (prev_point->data[DEMODdima] != curr_point->data[DEMODdima] || prev_point->data[DEMODdimP] != curr_point->data[DEMODdimP] || prev_point->data[DEMODdimT] != curr_point->data[DEMODdimT]) **/
2179 /** {
2180 dopplerShiftFlag = TRUE;
2181 }**/
2182
2183 /* save the current point into the previous point*/
2184 XLAL_CHECK( gsl_vector_memcpy( prev_point, curr_point ) == 0, XLAL_EFAILED );
2185
2186 /* Apply additional Doppler shifting using current binary orbital parameters */
2187 /* Might want to be clever about checking whether we've changed the orbital parameters or only the frequency */
2188 if ( dopplerShiftFlag == TRUE ) {
2189 if ( ( XLALAddMultiBinaryTimes( &multiBinaryTimes, multiSSBTimes, &dopplerpos ) != XLAL_SUCCESS ) ) {
2190 LogPrintf( LOG_CRITICAL, "%s: XLALAddMultiBinaryTimes() failed with errno=%d\n", __func__, xlalErrno );
2192 }
2193 *DEMODnumorb += 1;
2194 }
2195
2196 if ( ( XLALGetDopplerShiftedFrequencyInfo( shiftedFreqs, lowestBins, expSignalPhases, sincList, uvar.numBins, &dopplerpos, sftIndices, inputSFTs, multiBinaryTimes, badBins, Tsft ) != XLAL_SUCCESS ) ) {
2197 LogPrintf( LOG_CRITICAL, "%s: XLALGetDopplerShiftedFrequencyInfo() failed with errno=%d\n", __func__, xlalErrno );
2199 }
2200
2201 if ( ( XLALCalculatePulsarCrossCorrStatistic( &ccStat, &evSquared, GammaAve, expSignalPhases, lowestBins, sincList, sftPairs, sftIndices, inputSFTs, multiWeights, uvar.numBins ) != XLAL_SUCCESS ) ) {
2202 LogPrintf( LOG_CRITICAL, "%s: XLALCalculatePulsarCrossCorrStatistic() failed with errno=%d\n", __func__, xlalErrno );
2204 }
2205
2206 /* fill candidate struct and insert into toplist if necessary */
2207 thisCandidate.freq = dopplerpos.fkdot[0];
2208 thisCandidate.tp = XLALGPSGetREAL8( &dopplerpos.tp );
2209 thisCandidate.argp = dopplerpos.argp;
2210 thisCandidate.asini = dopplerpos.asini;
2211 thisCandidate.ecc = dopplerpos.ecc;
2212 thisCandidate.period = dopplerpos.period;
2213 thisCandidate.rho = ccStat;
2214 thisCandidate.evSquared = evSquared;
2215 thisCandidate.estSens = estSens;
2216
2217 insert_into_crossCorrBinary_toplist( ccToplist, thisCandidate );
2218
2219 //fprintf(stdout,"Inner loop: freq %f , tp %f , asini %f \n", thisCandidate.freq, thisCandidate.tp, thisCandidate.asini);
2220
2221 } /* end while loop over templates */
2222
2223 gsl_vector_free( curr_point );
2224 gsl_vector_free( prev_point );
2227 if ( LatticeFile != NULL ) {
2228 fclose( LatticeFile );
2229 }
2230 } else {
2231 /* args should be : spacings, min and max doppler params */
2232 BOOLEAN firstPoint = TRUE; /* a boolean to help to search at the beginning point in parameter space, after the search it is set to be FALSE to end the loop*/
2233 if ( ( XLALAddMultiBinaryTimes( &multiBinaryTimes, multiSSBTimes, &dopplerpos ) != XLAL_SUCCESS ) ) {
2234 LogPrintf( LOG_CRITICAL, "%s: XLALAddMultiBinaryTimes() failed with errno=%d\n", __func__, xlalErrno );
2236 } /*Need to apply additional doppler shifting before the loop, or the first point in parameter space will be lost and return a wrong SNR when fBand!=0*/
2237
2238 //fprintf(stdout, "Resampling? %s \n", uvar.resamp ? "true" : "false");
2239
2240 while ( GetNextCrossCorrTemplate( &dopplerShiftFlag, &firstPoint, &dopplerpos, &binaryTemplateSpacings, &minBinaryTemplate, &maxBinaryTemplate, &fCount, &aCount, &tCount, &pCount, fSpacingNum, aSpacingNum, tSpacingNum, pSpacingNum, config ) == 0 ) {
2241 /* do useful stuff here*/
2242
2243 /* Apply additional Doppler shifting using current binary orbital parameters */
2244 /* Might want to be clever about checking whether we've changed the orbital parameters or only the frequency */
2245 if ( dopplerShiftFlag == TRUE ) {
2246 if ( ( XLALAddMultiBinaryTimes( &multiBinaryTimes, multiSSBTimes, &dopplerpos ) != XLAL_SUCCESS ) ) {
2247 LogPrintf( LOG_CRITICAL, "%s: XLALAddMultiBinaryTimes() failed with errno=%d\n", __func__, xlalErrno );
2249 }
2250 }
2251
2252 if ( ( XLALGetDopplerShiftedFrequencyInfo( shiftedFreqs, lowestBins, expSignalPhases, sincList, uvar.numBins, &dopplerpos, sftIndices, inputSFTs, multiBinaryTimes, badBins, Tsft ) != XLAL_SUCCESS ) ) {
2253 LogPrintf( LOG_CRITICAL, "%s: XLALGetDopplerShiftedFrequencyInfo() failed with errno=%d\n", __func__, xlalErrno );
2255 }
2256
2257 if ( ( XLALCalculatePulsarCrossCorrStatistic( &ccStat, &evSquared, GammaAve, expSignalPhases, lowestBins, sincList, sftPairs, sftIndices, inputSFTs, multiWeights, uvar.numBins ) != XLAL_SUCCESS ) ) {
2258 LogPrintf( LOG_CRITICAL, "%s: XLALCalculatePulsarCrossCorrStatistic() failed with errno=%d\n", __func__, xlalErrno );
2260 }
2261
2262 /* fill candidate struct and insert into toplist if necessary */
2263 thisCandidate.freq = dopplerpos.fkdot[0];
2264 thisCandidate.tp = XLALGPSGetREAL8( &dopplerpos.tp );
2265 thisCandidate.argp = dopplerpos.argp;
2266 thisCandidate.asini = dopplerpos.asini;
2267 thisCandidate.ecc = dopplerpos.ecc;
2268 thisCandidate.period = dopplerpos.period;
2269 thisCandidate.rho = ccStat;
2270 thisCandidate.evSquared = evSquared;
2271 thisCandidate.estSens = estSens;
2272
2273 insert_into_crossCorrBinary_toplist( ccToplist, thisCandidate );
2274
2275 // fprintf(stdout,"Inner loop: freq %f , asini %f , tasc %f , porb %f \n", thisCandidate.freq, thisCandidate.asini, thisCandidate.tp, thisCandidate.period);
2276
2277 } /* end while loop over templates */
2278
2279
2280 }
2281
2282
2283
2284 return 0;
2285} /* end demodLoopCrossCorr */
2286
2287/* Function to isolate the loop for resampling */
2288/* No longer used anywhere */
2289/* int resampLoopCrossCorr(MultiSSBtimes *multiBinaryTimes, MultiSSBtimes *multiSSBTimes, PulsarDopplerParams dopplerpos, BOOLEAN dopplerShiftFlag, PulsarDopplerParams binaryTemplateSpacings, PulsarDopplerParams minBinaryTemplate, PulsarDopplerParams maxBinaryTemplate, UINT8 fCount, UINT8 aCount, UINT8 tCount, UINT8 pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, REAL8Vector *shiftedFreqs, UINT4Vector *lowestBins, COMPLEX8Vector *expSignalPhases, REAL8VectorSequence *sincList, UserInput_t uvar, SFTIndexList *sftIndices, MultiSFTVector *inputSFTs, MultiUINT4Vector *badBins, REAL8 Tsft, MultiNoiseWeights *multiWeights, REAL8 ccStat, REAL8 evSquared, REAL8 estSens, REAL8Vector *GammaAve, SFTPairIndexList *sftPairs, CrossCorrBinaryOutputEntry thisCandidate, toplist_t *ccToplist ){ */
2290/* /\* args should be : spacings, min and max doppler params *\/ */
2291/* BOOLEAN firstPoint = TRUE; /\* a boolean to help to search at the beginning point in parameter space, after the search it is set to be FALSE to end the loop*\/ */
2292/* if ( (XLALAddMultiBinaryTimes( &multiBinaryTimes, multiSSBTimes, &dopplerpos ) != XLAL_SUCCESS ) ) { */
2293/* LogPrintf ( LOG_CRITICAL, "%s: XLALAddMultiBinaryTimes() failed with errno=%d\n", __func__, xlalErrno ); */
2294/* XLAL_ERROR( XLAL_EFUNC ); */
2295/* } /\*Need to apply additional doppler shifting before the loop, or the first point in parameter space will be lost and return a wrong SNR when fBand!=0*\/ */
2296
2297/* //fprintf(stdout, "Resampling? %s \n", uvar.resamp ? "true" : "false"); */
2298
2299/* while ( GetNextCrossCorrTemplateResamp(&dopplerShiftFlag, &firstPoint, &dopplerpos, &binaryTemplateSpacings, &minBinaryTemplate, &maxBinaryTemplate, &fCount, &aCount, &tCount, &pCount, fSpacingNum, aSpacingNum, tSpacingNum, pSpacingNum) == 0) */
2300/* { */
2301/* /\* do useful stuff here*\/ */
2302
2303/* /\* Apply additional Doppler shifting using current binary orbital parameters *\/ */
2304/* /\* Might want to be clever about checking whether we've changed the orbital parameters or only the frequency *\/ */
2305/* if (dopplerShiftFlag == TRUE) */
2306/* { */
2307/* if ( (XLALAddMultiBinaryTimes( &multiBinaryTimes, multiSSBTimes, &dopplerpos ) != XLAL_SUCCESS ) ) { */
2308/* LogPrintf ( LOG_CRITICAL, "%s: XLALAddMultiBinaryTimes() failed with errno=%d\n", __func__, xlalErrno ); */
2309/* XLAL_ERROR( XLAL_EFUNC ); */
2310/* } */
2311/* } */
2312
2313/* if ( (XLALGetDopplerShiftedFrequencyInfo( shiftedFreqs, lowestBins, expSignalPhases, sincList, uvar.numBins, &dopplerpos, sftIndices, inputSFTs, multiBinaryTimes, badBins, Tsft ) != XLAL_SUCCESS ) ) { */
2314/* LogPrintf ( LOG_CRITICAL, "%s: XLALGetDopplerShiftedFrequencyInfo() failed with errno=%d\n", __func__, xlalErrno ); */
2315/* XLAL_ERROR( XLAL_EFUNC ); */
2316/* } */
2317
2318/* if ( (XLALCalculatePulsarCrossCorrStatistic( &ccStat, &evSquared, GammaAve, expSignalPhases, lowestBins, sincList, sftPairs, sftIndices, inputSFTs, multiWeights, uvar.numBins) != XLAL_SUCCESS ) ) { */
2319/* LogPrintf ( LOG_CRITICAL, "%s: XLALCalculatePulsarCrossCorrStatistic() failed with errno=%d\n", __func__, xlalErrno ); */
2320/* XLAL_ERROR( XLAL_EFUNC ); */
2321/* } */
2322
2323/* /\* fill candidate struct and insert into toplist if necessary *\/ */
2324/* thisCandidate.freq = dopplerpos.fkdot[0]; */
2325/* thisCandidate.tp = XLALGPSGetREAL8( &dopplerpos.tp ); */
2326/* thisCandidate.argp = dopplerpos.argp; */
2327/* thisCandidate.asini = dopplerpos.asini; */
2328/* thisCandidate.ecc = dopplerpos.ecc; */
2329/* thisCandidate.period = dopplerpos.period; */
2330/* thisCandidate.rho = ccStat; */
2331/* thisCandidate.evSquared = evSquared; */
2332/* thisCandidate.estSens = estSens; */
2333
2334/* insert_into_crossCorrBinary_toplist(ccToplist, thisCandidate); */
2335
2336/* fprintf(stdout,"Inner loop: freq %f , tp %f , asini %f \n", thisCandidate.freq, thisCandidate.tp, thisCandidate.asini); */
2337
2338/* } /\* end while loop over templates *\/ */
2339/* return 0; */
2340/* } /\* end resampLoopCrossCorr *\/ */
2341
2342/** For-loop function for resampling */
2343int resampForLoopCrossCorr( PulsarDopplerParams dopplerpos, BOOLEAN dopplerShiftFlag, PulsarDopplerParams binaryTemplateSpacings, PulsarDopplerParams minBinaryTemplate, PulsarDopplerParams maxBinaryTemplate, UINT8 fCount, UINT8 aCount, UINT8 tCount, UINT8 pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, UserInput_t uvar, MultiNoiseWeights *multiWeights, UINT4 *numSamplesFFT, REAL8Vector *ccStatVector, REAL8Vector *evSquaredVector, REAL8Vector *numeEquivAve, REAL8Vector *numeEquivCirc, REAL8 estSens, REAL8Vector *resampGammaAve, MultiResampSFTPairMultiIndexList *resampMultiPairs, CrossCorrBinaryOutputEntry thisCandidate, toplist_t *ccToplist, REAL8 tShort, ConfigVariables *config )
2344{
2345
2346
2347 /* Prepare Fstat user input and output array, so remember that
2348 * we should destroy them later */
2349
2350 /* Setup optional arguments */
2352 optionalArgs.Dterms = uvar.Dterms;
2353 optionalArgs.FstatMethod = FMETHOD_RESAMP_BEST;
2354 optionalArgs.runningMedianWindow = 100;
2355 optionalArgs.resampFFTPowerOf2 = FALSE;
2356 /* Optional injections */
2357 PulsarParamsVector *injectSources = NULL;
2358 MultiNoiseFloor *injectSqrtSX = NULL;
2359 optionalArgs.injectSqrtSX = injectSqrtSX;
2360 if ( uvar.injectionSources != NULL ) {
2361 XLAL_CHECK_MAIN( ( injectSources = XLALPulsarParamsFromUserInput( uvar.injectionSources, NULL ) ) != NULL, XLAL_EFUNC );
2362 }
2363 optionalArgs.injectSources = injectSources;
2364 optionalArgs.injectSqrtSX = injectSqrtSX;
2365 optionalArgs.allowedMismatchFromSFTLength = uvar.allowedMismatchFromSFTLength;
2366
2367 /* Set environmental variable for Fstat FFT planning: creating F stat input
2368 * automatically invokes the FFT planner, but we never use it, so want to
2369 * minimize wasted time (CrossCorr FFTs are planned when we create the
2370 * CrossCorr workspace instead). If the variable is not set, FFTW measure is
2371 * used, which takes extremely long, because it repeatedly measures the time
2372 * for an FFT of length equal to Tobs. */
2373 XLAL_CHECK( setenv( "LAL_FSTAT_FFT_PLAN_MODE", "ESTIMATE", 1 ) == XLAL_SUCCESS, ENOMEM );
2374
2375 /* Prepare Fstat input, containing SFTs and data used overall */
2376 //LIGOTimeGPS startTimeGPS = {(INT4)uvar.startTime, 0.0};
2377 //LIGOTimeGPS endTimeGPS = {(INT4)uvar.endTime, 0.0};
2378 //printf("start, start %d, %f\n", uvar.endTime, XLALGPSGetREAL8(&endTimeGPS));
2379 REAL8 Tobs = ( REAL8 )( uvar.endTime - uvar.startTime );
2380 REAL8 dFreq = 1.0 / Tobs; /* Reinhard's trick for resamp function*/
2381 REAL8 fCoverMin, fCoverMax;
2382 const REAL8 binaryMaxAsini = MYMAX( uvar.orbitAsiniSec, uvar.orbitAsiniSec + uvar.orbitAsiniSecBand );
2383 const REAL8 binaryMinPorb = MYMIN( uvar.orbitPSec, uvar.orbitPSec + uvar.orbitPSecBand );
2384 /* for now, a zero-eccentricity search with no spindown */
2385 const REAL8 binaryMaxEcc = 0.0;
2386 //PulsarSpinRange spinRangeRef;
2387 REAL8 extraPerFreq = 1.05 * LAL_TWOPI / LAL_C_SI * ( ( LAL_AU_SI / LAL_YRSID_SI ) + ( LAL_REARTH_SI / LAL_DAYSID_SI ) );
2388 REAL8 maxOmega = LAL_TWOPI / binaryMinPorb;
2389 extraPerFreq += maxOmega * binaryMaxAsini / ( 1.0 - binaryMaxEcc );
2390 fCoverMin = ( uvar.fStart ) * ( 1.0 - extraPerFreq );
2391 fCoverMax = ( uvar.fStart + uvar.fBand ) * ( 1.0 + extraPerFreq );
2392 //printf("%f %f\n", (2 * LAL_PI * binaryMaxAsini)/binaryMinPorb, extraPerFreq);
2393 //fCoverMin = uvar.fStart * (1.0 - (2 * LAL_PI * binaryMaxAsini)/binaryMinPorb);
2394 //fCoverMax = (uvar.fStart + uvar.fBand) * (1 + (2 * LAL_PI * binaryMaxAsini)/binaryMinPorb);
2395 //XLALCWSignalCoveringBand( &fCoverMin, &fCoverMax, &startTimeGPS, &endTimeGPS, &spinRangeRef, binaryMaxAsini, binaryMinPorb, binaryMaxEcc);
2396 //printf("min, max %f, %f\n", fCoverMin, fCoverMax);
2397 /* Important: resampling uses 8 bins on either side, 16 total, to buffer
2398 * the SFTs read in from the catalog by create f-stat input.
2399 * If 16 / t_sft is comparable to the difference of cover
2400 * max and cover min frequencies, or larger, all downstream processes
2401 * will be slowed down. This problem arises because the time interval
2402 * in the detector and source frame time series is shorter in both cases
2403 * than would be expected from the cover. For example, the number of
2404 * samples per FFT will be larger than expected, causing the statistic
2405 * calculation to slow down. To avoid, increase t_sft and f_band.
2406 * Slowdown very approximately theoretically proportional to
2407 * (16 / t_sft + f_cover_max - f_cover_min)/(f_cover_max - f_cover_min)
2408 * n.b.,
2409 * t_short is a separate issue and in any case should = maxLag for speed.
2410 * Note that f_band should be as large a proportion as possible of
2411 * the cover, to minimize wasted time on Doppler wings. This is a separate
2412 * issue that is only solved by increasing f_band. Slowdown approximately
2413 * (f_cover_max - f_cover_min )/( f_band )
2414 * Finally, see note about Dterms in the init vars function: slowdown in
2415 * the FFT is proportional to (1 + 2/ (2 Dterms + 1)). However, fewer
2416 * Dterms makes the barycentering faster, linearly prop to Dterms.
2417 * Solving for the case when barycentering and FFT costs are about equal
2418 * at 128 Dterms implied that the optimum total cost has about Dterms = 8.
2419 * To be clear, this is not the same issue as the 16 bin buffer.
2420 */
2421 FstatInput *resampFstatInput = NULL;
2422 XLAL_CHECK( ( ( resampFstatInput ) = XLALCreateFstatInput( config->catalog, fCoverMin, fCoverMax, dFreq, config->edat, &optionalArgs ) ) != NULL, XLAL_EFUNC );
2423
2424 /* Free injection parameters if used */
2425 if ( optionalArgs.injectSources ) {
2427 }
2428 /* Set the number of frequencies to look at in resamp,
2429 * adding one since we are counting from zero */
2430 UINT8 fCountResamp = fSpacingNum + 1; // Number of frequencies
2431
2432 /* Take as much preperation as possible outside the hotloop */
2433 FstatResults *Fstat_results = NULL;
2434 FstatResults **Fstats = &( Fstat_results );
2435 const UINT4 numFreqBins = fCountResamp;
2436 /* Only compute the resampled time series*/
2437 const FstatQuantities whatToCompute = FSTATQ_NONE;
2438 XLAL_CHECK( numFreqBins > 0, XLAL_EINVAL );
2439 if ( *( Fstats ) == NULL ) {
2440 XLAL_CHECK( ( ( *Fstats ) = XLALCalloc( 1, sizeof( **Fstats ) ) ) != NULL, XLAL_ENOMEM );
2441 }
2442 ( *Fstats )->dFreq = 1.0 / Tobs;
2443 ( *Fstats )->numFreqBins = numFreqBins;
2444 XLAL_INIT_MEM( ( *Fstats )->detectorNames );
2445 ( *Fstats )->whatWasComputed = whatToCompute;
2446 /* The aim of the F-stat calls: the time series, a(t)x(t) and b(t)x(t) */
2447 MultiCOMPLEX8TimeSeries *multiTimeSeries_SRC_a = NULL;
2448 MultiCOMPLEX8TimeSeries *multiTimeSeries_SRC_b = NULL;
2449
2450 ResampCrossCorrWorkspace *ws = NULL;
2451 COMPLEX8 *ws1KFaX_k = NULL;
2452 COMPLEX8 *ws1KFbX_k = NULL;
2453 COMPLEX8 *ws2LFaX_k = NULL;
2454 COMPLEX8 *ws2LFbX_k = NULL;
2455 REAL8 Tcoh = 2 * resampMultiPairs->maxLag + tShort;
2456 if ( ( XLALCreateCrossCorrWorkspace( &ws, &ws1KFaX_k, &ws1KFbX_k, &ws2LFaX_k, &ws2LFbX_k, &multiTimeSeries_SRC_a, &multiTimeSeries_SRC_b, binaryTemplateSpacings, resampFstatInput, numFreqBins, Tcoh, uvar.treatWarningsAsErrors ) != XLAL_SUCCESS ) ) {
2457 LogPrintf( LOG_CRITICAL, "%s: XLALCreateCrossCorrWorkspace() failed with errno=%d\n", __func__, xlalErrno );
2459 }
2460
2461 /* printf( "numSamplesFFT: %u\n", ws->numSamplesFFT ); */
2462 *numSamplesFFT = ws->numSamplesFFT;
2463
2464 for ( tCount = 0; tCount <= tSpacingNum; tCount++ ) {
2465 for ( pCount = 0; pCount <= pSpacingNum; pCount++ ) {
2466 for ( aCount = 0; aCount <= aSpacingNum; aCount++ ) {
2467
2468 fCount = 0; /* over orb params, reset to zero b/c output loop increments */
2469
2470 if ( ( GetNextCrossCorrTemplateForResamp( &dopplerShiftFlag, &dopplerpos, &binaryTemplateSpacings, &minBinaryTemplate, &maxBinaryTemplate, &fCount, &aCount, &tCount, &pCount, config ) ) != 0 ) {
2471 LogPrintf( LOG_CRITICAL, "%s: XLALGetNextCrossCorrTemplateForResamp() failed with errno=%d\n", __func__, xlalErrno );
2473 }
2474
2475 /* Call ComputeFstat to make the resampled time series; given the
2476 * "none" whatToCompute flag, will skip the F-stat computation */
2477 XLAL_CHECK( ( XLALComputeFstat( Fstats, resampFstatInput, &dopplerpos, fCountResamp, whatToCompute ) == XLAL_SUCCESS ), XLAL_EFUNC );
2478 /* Return a resampled time series */
2479 XLAL_CHECK( ( XLALExtractResampledTimeseries( &multiTimeSeries_SRC_a, &multiTimeSeries_SRC_b, resampFstatInput ) == XLAL_SUCCESS ), XLAL_EFUNC );
2480
2481 /* Calculate the CrossCorr rho statistic using resampling */
2482 if ( ( XLALCalculatePulsarCrossCorrStatisticResamp( ccStatVector, evSquaredVector, numeEquivAve, numeEquivCirc, resampGammaAve, resampMultiPairs, multiWeights, &binaryTemplateSpacings, &dopplerpos, multiTimeSeries_SRC_a, multiTimeSeries_SRC_b, ws, ws1KFaX_k, ws1KFbX_k, ws2LFaX_k, ws2LFbX_k ) != XLAL_SUCCESS ) ) {
2483 LogPrintf( LOG_CRITICAL, "%s: XLALCalculatePulsarCrossCorrStatisticResamp() failed with errno=%d\n", __func__, xlalErrno );
2485 }
2486 for ( fCount = 0; fCount <= fSpacingNum; fCount++ ) {
2487 /* New, adapted for resampling:
2488 * fill candidate struct and insert into toplist if necessary */
2489 thisCandidate.freq = dopplerpos.fkdot[0] + fCount * binaryTemplateSpacings.fkdot[0];
2490 thisCandidate.tp = XLALGPSGetREAL8( &dopplerpos.tp );
2491 thisCandidate.argp = dopplerpos.argp;
2492 thisCandidate.asini = dopplerpos.asini;
2493 thisCandidate.ecc = dopplerpos.ecc;
2494 thisCandidate.period = dopplerpos.period;
2495 thisCandidate.rho = ccStatVector->data[fCount];
2496 thisCandidate.evSquared = evSquaredVector->data[fCount];
2497 thisCandidate.estSens = estSens;
2498 insert_into_crossCorrBinary_toplist( ccToplist, thisCandidate );
2499 } // end fCount for writing toplist
2500 } // end aCount
2501 } // end pCount
2502 } /* end tCount, and with it, for loop over templates */
2503
2505 fftw_free( ws1KFaX_k );
2506 fftw_free( ws1KFbX_k );
2507 fftw_free( ws2LFaX_k );
2508 fftw_free( ws2LFbX_k );
2509
2510 /* Destroy Fstat input */
2511 XLALDestroyFstatInput( resampFstatInput );
2512 /* Destroy resampled input and time structures, which use much memory */
2513 XLALDestroyFstatResults( Fstat_results );
2514 return 0;
2515} /* end resampForLoopCrossCorr */
2516
2517int testShortFunctionsBlock( UserInput_t uvar, MultiSFTVector *inputSFTs, REAL8 Tsft, REAL8 resampTshort, SFTIndexList **sftIndices, SFTPairIndexList **sftPairs, REAL8Vector **GammaAve, REAL8Vector **GammaCirc, MultiResampSFTPairMultiIndexList **resampMultiPairs, MultiLALDetector *multiDetectors, MultiDetectorStateSeries **multiStates, MultiDetectorStateSeries **resampMultiStates, MultiNoiseWeights **multiWeights, MultiLIGOTimeGPSVector **multiTimes, MultiLIGOTimeGPSVector **resampMultiTimes, MultiSSBtimes **multiSSBTimes, REAL8VectorSequence **phaseDerivs, gsl_matrix **g_ij, gsl_vector **eps_i, REAL8 estSens, SkyPosition *skyPos, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *thisBinaryTemplate, ConfigVariables config, const DopplerCoordinateSystem coordSys )
2518{
2519 /* Caution: this block will use a variety of "short" functions that
2520 * were made in the process of developing the tShort argument. None
2521 * of these functions are needed to use tShort. They simply provide
2522 * an alternative pathway by which to achieve an answer than should
2523 * be within about a percent (in rho) of the answer found by using
2524 * modified timestamps and SFT weights. The remaining discrepancy
2525 * stems, as far as discernable, from the use of detector rather
2526 * than solar-system barycenter times in computing the timestamps
2527 * for phase derivatives, thereby slightly altering the metric
2528 * spacing and thus the template grid locations. The use of this
2529 * function is not recommended for production, simply because it
2530 * has more functions that differ from the already-reviewed demod
2531 * search. However, this function should provide a useful sanity
2532 * check on results from the resampling-with-tShort standard method
2533 * and thus could help expedite review in the future. */
2534 printf( "starting short functions block at time: %f\n", XLALGetTimeOfDay() );
2535 MultiREAL8TimeSeries *scienceFlagVect = NULL;
2536 MultiAMCoeffs *resampMultiCoeffs = NULL;
2537 UINT4 numShortPerDet = 0;
2538 if ( ( numShortPerDet = XLALCrossCorrNumShortPerDetector( resampTshort, uvar.startTime, uvar.endTime ) ) == 0 ) {
2539 LogPrintf( LOG_CRITICAL, "%s: XLALCrossCorrNumShortPerDetector() failed with errno=%d\n", __func__, xlalErrno );
2541 }
2542 MultiPSDVector *multiPSDs = NULL;
2543 MultiLIGOTimeGPSVector *multiTimesNew = NULL;
2544 MultiNoiseWeights *multiWeightsNew = NULL;
2545 SFTIndexList *sftIndicesNew = NULL;
2546
2547 REAL8 deltaF = config.catalog->data[0].header.deltaF;
2548 REAL8 vMax = LAL_TWOPI * ( uvar.orbitAsiniSec + uvar.orbitAsiniSecBand ) / uvar.orbitPSec + LAL_TWOPI * LAL_REARTH_SI / ( LAL_DAYSID_SI * LAL_C_SI ) + LAL_TWOPI * LAL_AU_SI / ( LAL_YRSID_SI * LAL_C_SI ); /*calculate the maximum relative velocity in speed of light*/
2549 REAL8 fMin = uvar.fStart * ( 1 - vMax ) - 0.5 * uvar.rngMedBlock * deltaF;
2550 REAL8 fMax = ( uvar.fStart + uvar.fBand ) * ( 1 + vMax ) + 0.5 * uvar.rngMedBlock * deltaF;
2551
2552 /* read the SFTs*/
2553 MultiSFTVector *inputSFTsAlt = NULL;
2554 if ( ( inputSFTsAlt = XLALLoadMultiSFTs( config.catalog, fMin, fMax ) ) == NULL ) {
2555 LogPrintf( LOG_CRITICAL, "%s: XLALLoadMultiSFTs() failed with errno=%d\n", __func__, xlalErrno );
2557 }
2558 inputSFTs = inputSFTsAlt;
2559
2560 /* calculate the psd and normalize the SFTs */
2561 if ( ( multiPSDs = XLALNormalizeMultiSFTVect( inputSFTsAlt, uvar.rngMedBlock, NULL ) ) == NULL ) {
2562 LogPrintf( LOG_CRITICAL, "%s: XLALNormalizeMultiSFTVect() failed with errno=%d\n", __func__, xlalErrno );
2564 }
2565
2566 /* compute the noise weights for the AM coefficients */
2567 XLALDestroyMultiNoiseWeights( *multiWeights );
2568 if ( ( multiWeightsNew = XLALComputeMultiNoiseWeights( multiPSDs, uvar.rngMedBlock, 0 ) ) == NULL ) {
2569 LogPrintf( LOG_CRITICAL, "%s: XLALComputeMultiNoiseWeights() failed with errno=%d\n", __func__, xlalErrno );
2571 }
2572 ( *multiWeights ) = multiWeightsNew;
2573
2574 /* read the timestamps from the SFTs */
2575 if ( ( multiTimesNew = XLALExtractMultiTimestampsFromSFTs( inputSFTs ) ) == NULL ) {
2576 LogPrintf( LOG_CRITICAL, "%s: XLALExtractMultiTimestampsFromSFTs() failed with errno=%d\n", __func__, xlalErrno );
2578 }
2579 ( *multiTimes ) = multiTimesNew;
2580
2581 /* Try to get modified detector states */
2582 MultiLALDetector multiDetectorsNew;
2583
2584 /* read the detector information from the SFTs */
2585 if ( XLALMultiLALDetectorFromMultiSFTs( &multiDetectorsNew, inputSFTs ) != XLAL_SUCCESS ) {
2586 LogPrintf( LOG_CRITICAL, "%s: XLALMultiLALDetectorFromMultiSFTs() failed with errno=%d\n", __func__, xlalErrno );
2588 }
2589 ( *multiDetectors ) = ( multiDetectorsNew );
2590
2591 /* read the timestamps from the SFTs */
2592 XLALDestroyMultiTimestamps( *resampMultiTimes );
2593 if ( ( *( resampMultiTimes ) = XLALExtractMultiTimestampsFromSFTsShort( &scienceFlagVect, inputSFTs, resampTshort, numShortPerDet ) ) == NULL ) {
2594 LogPrintf( LOG_CRITICAL, "%s: XLALExtractMultiTimestampsFromSFTShorts() failed with errno=%d\n", __func__, xlalErrno );
2596 }
2597
2598 /* Find the detector state for each SFT */
2599 if ( ( *( resampMultiStates ) = XLALGetMultiDetectorStatesShort( *( resampMultiTimes ), &( multiDetectorsNew ), config.edat, 0.5 * resampTshort, resampTshort, numShortPerDet ) ) == NULL ) {
2600 LogPrintf( LOG_CRITICAL, "%s: XLALGetMultiDetectorStatesShort() failed with errno=%d\n", __func__, xlalErrno );
2602 }
2604 *( multiStates ) = *( resampMultiStates );
2605
2606 XLALDestroySFTIndexList( *sftIndices );
2607 if ( ( XLALCreateSFTIndexListFromMultiSFTVect( &sftIndicesNew, inputSFTs ) != XLAL_SUCCESS ) ) {
2608 LogPrintf( LOG_CRITICAL, "%s: XLALCreateSFTIndexListFromMultiSFTVect() failed with errno=%d\n", __func__, xlalErrno );
2610 }
2611 ( *sftIndices ) = sftIndicesNew;
2612
2613 /* Calculate the resampled AM coefficients (a,b) for each tShort */
2614 /* At moment, looks like we do want multiTimes, not resampMultiTimes,
2615 * because the need to know original SFT times for weights,
2616 * and the resamp times are easy to regenerate inside */
2617 if ( ( resampMultiCoeffs = XLALComputeMultiAMCoeffsShort( *( resampMultiStates ), *( multiWeights ), *( skyPos ), resampTshort, Tsft, numShortPerDet, *( multiTimes ) ) ) == NULL ) {
2618 LogPrintf( LOG_CRITICAL, "%s: XLALComputeMultiAMCoeffs() failed with errno=%d\n", __func__, xlalErrno );
2620 }
2621 ///* Be careful NOT to double-weight the coefficients: this is a separate test */
2622 ///* Note that the weighting is the only place where multiTimes are used,
2623 // and for that, the old vector is the right one, because we need to
2624 // know when the old SFTs were */
2625 ///* apply noise-weights and compute antenna-pattern matrix {A,B,C} */
2626 //if ( XLALWeightMultiAMCoeffsShort ( resampMultiCoeffs, multiWeights, resampTshort, Tsft, numShortPerDet, multiTimes ) != XLAL_SUCCESS ) {
2627 // /* Turns out tShort and tSFTOld are, surprisingly, irrelevant (I think) */
2628 // XLALPrintError ("%s: call to XLALWeightMultiAMCoeffs() failed with xlalErrno = %d\n", __func__, xlalErrno );
2629 // XLALDestroyMultiAMCoeffs ( resampMultiCoeffs );
2630 // XLAL_ERROR ( XLAL_EFUNC );
2631 //}
2632
2633 /* Rerun to get the sftPairs list for all the old-school functions that use it */
2634 SFTPairIndexList *sftPairsNew = NULL;
2635 if ( ( XLALCreateSFTPairIndexList( &( sftPairsNew ), ( *sftIndices ), inputSFTs, uvar.maxLag, uvar.inclAutoCorr ) != XLAL_SUCCESS ) ) {
2636 LogPrintf( LOG_CRITICAL, "%s: XLALCreateSFTPairIndexList() failed with errno=%d\n", __func__, xlalErrno );
2638 }
2639 XLALDestroySFTPairIndexList( * sftPairs );
2640 ( *sftPairs ) = sftPairsNew;
2641
2642 fprintf( stdout, "Number of detectors in SFT list: %u\n", ( *resampMultiTimes )->length );
2643 MultiResampSFTPairMultiIndexList *resampMultiPairsNew = NULL;
2644 /* Run modified pair maker for resampling with tShort */
2645 if ( ( XLALCreateSFTPairIndexListShortResamp( &( resampMultiPairsNew ), uvar.maxLag, uvar.inclAutoCorr, uvar.inclSameDetector, Tsft, ( *resampMultiTimes ) ) != XLAL_SUCCESS ) ) {
2646 LogPrintf( LOG_CRITICAL, "%s: XLALCreateSFTPairIndexListShortResamp() failed with errno=%d\n", __func__, xlalErrno );
2648 }
2649
2650 XLALDestroyMultiResampSFTPairMultiIndexList( * resampMultiPairs );
2651 ( *resampMultiPairs ) = resampMultiPairsNew;
2652 XLALDestroySFTIndexList( *sftIndices );
2653 XLALDestroySFTPairIndexList( *sftPairs );
2654 ( *sftIndices ) = ( *resampMultiPairs )->indexList ;
2655 ( *sftPairs ) = ( *resampMultiPairs )->pairIndexList ;
2656 /* Optional: sanity check the pairs list -- very long standard output */
2657 //XLAL_CHECK( ( XLALTestResampPairIndexList( (*resampMultiPairs) ) == XLAL_SUCCESS), XLAL_EFUNC);
2658
2659 /* Do a resample-indexed version */
2660 REAL8Vector *intermediateGammaAve = NULL;
2661 REAL8Vector *intermediateGammaCirc = NULL;
2662 /* Actually use these vectors */
2663 REAL8Vector *resampGammaAve = NULL;
2664 REAL8Vector *resampGammaCirc = NULL;
2665
2666 if ( ( XLALCalculateCrossCorrGammasResampShort( &intermediateGammaAve, &intermediateGammaCirc, *( resampMultiPairs ), resampMultiCoeffs ) != XLAL_SUCCESS ) ) {
2667 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateCrossCorrGammasResampShort() failed with errno=%d\n", __func__, xlalErrno );
2669 }
2670 XLALDestroyREAL8Vector( *GammaAve );
2671 XLALDestroyREAL8Vector( *GammaCirc );
2672 *( GammaAve ) = intermediateGammaAve;
2673 *( GammaCirc ) = intermediateGammaCirc;
2674 resampGammaAve = intermediateGammaAve;
2675 resampGammaCirc = intermediateGammaCirc;
2676
2677 MultiSSBtimes *shortMultiSSBTimes = NULL;
2678 if ( ( shortMultiSSBTimes = XLALGetMultiSSBtimes( *( resampMultiStates ), *( skyPos ), ( *dopplerpos ).refTime, SSBPREC_RELATIVISTICOPT ) ) == NULL ) {
2679 LogPrintf( LOG_CRITICAL, "%s: XLALGetMultiSSBtimes() failed with errno=%d\n", __func__, xlalErrno );
2681 }
2682 XLALDestroyMultiSSBtimes( *multiSSBTimes );
2683 *( multiSSBTimes ) = shortMultiSSBTimes;
2684
2685 REAL8 old_diagff = 0; /*diagonal metric components*/
2686 REAL8 old_diagaa = 0;
2687 REAL8 old_diagTT = 0;
2688 REAL8 old_diagpp = 0;
2689 estSens = 0;
2690 PulsarDopplerParams thisBinaryTemplateNew;
2691 thisBinaryTemplateNew = ( *thisBinaryTemplate );
2692
2693 /* ANSWER: this modify-timestamp test does not work yet, get a segfault */
2694 //MultiSFTVector* psuedoSFTsForTimes = NULL;
2695 //psuedoSFTsForTimes = XLALModifyCrossCorrTimestampsIntoSFTVector( multiTimes );
2696 //if ( (XLALCalculateLMXBCrossCorrDiagMetric(&estSens, &old_diagff, &old_diagaa, &old_diagTT, &old_diagpp, &weightedMuTAve, thisBinaryTemplate, GammaAve, sftPairs, sftIndices, psuedoSFTsForTimes, multiWeights /*, kappaValues*/) != XLAL_SUCCESS ) ) {
2697
2698 if ( ( XLALCalculateLMXBCrossCorrDiagMetricShort( &estSens, &old_diagff, &old_diagaa, &old_diagTT, &old_diagpp, thisBinaryTemplateNew, resampGammaAve, *( resampMultiPairs ), *( resampMultiTimes ), *( multiWeights ) /*, kappaValues*/ ) != XLAL_SUCCESS ) ) {
2699 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateLMXBCrossCorrDiagMetricShort() failed with errno=%d\n", __func__, xlalErrno );
2701 }
2702 REAL8VectorSequence *phaseDerivsNew = NULL;
2703 /* Note that the sft indices are not actually used by this function */
2704 if ( ( XLALCalculateCrossCorrPhaseDerivativesShort( &( phaseDerivsNew ), &( thisBinaryTemplateNew ), config.edat, ( *sftIndices ), *( resampMultiPairs ), *( multiSSBTimes ), &coordSys ) != XLAL_SUCCESS ) ) {
2705 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateCrossCorrPhaseDerivativesShort() failed with errno=%d\n", __func__, xlalErrno );
2707 }
2708 XLALDestroyREAL8VectorSequence( *phaseDerivs );
2709 ( *phaseDerivs ) = phaseDerivsNew;
2710 ( *thisBinaryTemplate ) = thisBinaryTemplateNew;
2711
2712 REAL8 sumGammaSq = 0;
2713 gsl_matrix *g_ijNew = NULL;
2714 gsl_vector *eps_iNew = NULL;
2715 if ( ( XLALCalculateCrossCorrPhaseMetricShort( &( g_ijNew ), &( eps_iNew ), &sumGammaSq, *( phaseDerivs ), *( resampMultiPairs ), resampGammaAve, resampGammaCirc, &coordSys ) != XLAL_SUCCESS ) ) {
2716 LogPrintf( LOG_CRITICAL, "%s: XLALCalculateCrossCorrPhaseMetricShort() failed with errno=%d\n", __func__, xlalErrno );
2718 }
2719 /* free metric and offset */
2720 gsl_matrix_free( *g_ij );
2721 gsl_vector_free( *eps_i );
2722
2723 ( *g_ij ) = g_ijNew;
2724 ( *eps_i ) = eps_iNew;
2725
2726 *( GammaAve ) = resampGammaAve;
2727 *( GammaCirc ) = resampGammaCirc;
2728
2729 XLALDestroyMultiPSDVector( multiPSDs );
2730 XLALDestroyMultiSFTVector( inputSFTs );
2731 XLALDestroyMultiAMCoeffs( resampMultiCoeffs );
2732 XLALDestroyMultiTimestamps( *resampMultiTimes );
2733 XLALDestroyMultiREAL8TimeSeries( scienceFlagVect );
2734 printf( "ending short functions block at time: %f\n", XLALGetTimeOfDay() );
2735 fprintf( stdout, "Using resampling for CrossCorr\n" );
2736 fprintf( stdout, "Resampling? %s \n", uvar.resamp ? "true" : "false" );
2737
2738 return XLAL_SUCCESS;
2739} /* end testShortFunctionsBlock*/
void sort_crossCorrBinary_toplist(toplist_t *l)
#define __func__
log an I/O error, i.e.
void free_crossCorr_toplist(toplist_t **l)
frees the space occupied by the toplist
int final_write_crossCorrBinary_toplist_to_file(toplist_t *l, const char *filename, UINT4 *checksum)
int create_crossCorrBinary_toplist(toplist_t **tl, UINT8 length)
int insert_into_crossCorrBinary_toplist(toplist_t *tl, CrossCorrBinaryOutputEntry elem)
int j
int k
void LALCheckMemoryLeaks(void)
#define LALFree(p)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
#define STRING(a)
#define fscanf
#define fprintf
int XLALSetLatticeTilingPorbEllipticalBound(LatticeTiling *tiling, const size_t tasc_dimension, const size_t porb_dimension, const double P0, const double sigP, const double T0, const double sigT, const int norb, const double nsigma, const BOOLEAN useShearedPeriod)
Set an orbital period as a function of time of ascension.
int l
REAL8VectorSequence * XLALCreateREAL8VectorSequence(UINT4 length, UINT4 veclen)
void XLALDestroyREAL8VectorSequence(REAL8VectorSequence *vecseq)
void XLALDestroyUINT4VectorSequence(UINT4VectorSequence *vecseq)
PulsarParamsVector * XLALPulsarParamsFromUserInput(const LALStringVector *UserInput, const LIGOTimeGPS *refTimeDef)
Function to determine the PulsarParamsVector input from a user-input defining CW sources.
void XLALDestroyPulsarParamsVector(PulsarParamsVector *ppvect)
Destructor for PulsarParamsVector type.
int XLALCWMakeFakeMultiData(MultiSFTVector **multiSFTs, MultiREAL8TimeSeries **multiTseries, const PulsarParamsVector *injectionSources, const CWMFDataParams *dataParams, const EphemerisData *edat)
Generate fake 'CW' data, returned either as SFTVector or REAL4Timeseries or both, for given CW-signal...
const FstatOptionalArgs FstatOptionalArgsDefaults
Global initializer for setting FstatOptionalArgs to default values.
Definition: ComputeFstat.c:90
int XLALExtractResampledTimeseries(MultiCOMPLEX8TimeSeries **multiTimeSeries_SRC_a, MultiCOMPLEX8TimeSeries **multiTimeSeries_SRC_b, FstatInput *input)
Extracts the resampled timeseries from a given FstatInput structure (must have been initialized previ...
void XLALDestroyFstatInput(FstatInput *input)
Free all memory associated with a FstatInput structure.
Definition: ComputeFstat.c:885
FstatQuantities
Bit-field of -statistic quantities which can be computed by XLALComputeFstat().
Definition: ComputeFstat.h:94
FstatInput * XLALCreateFstatInput(const SFTCatalog *SFTcatalog, const REAL8 minCoverFreq, const REAL8 maxCoverFreq, const REAL8 dFreq, const EphemerisData *ephemerides, const FstatOptionalArgs *optionalArgs)
Create a fully-setup FstatInput structure for computing the -statistic using XLALComputeFstat().
Definition: ComputeFstat.c:359
int XLALComputeFstat(FstatResults **Fstats, FstatInput *input, const PulsarDopplerParams *doppler, const UINT4 numFreqBins, const FstatQuantities whatToCompute)
Compute the -statistic over a band of frequencies.
Definition: ComputeFstat.c:760
void XLALDestroyFstatResults(FstatResults *Fstats)
Free all memory associated with a FstatResults structure.
Definition: ComputeFstat.c:934
@ FMETHOD_RESAMP_BEST
Resamp: best guess of the fastest available implementation
Definition: ComputeFstat.h:125
@ FSTATQ_NONE
Do not compute -statistic, still compute buffered quantities.
Definition: ComputeFstat.h:95
LIGOTimeGPS * XLALGPSTimeNow(LIGOTimeGPS *gpstime)
void XLALDestroyMultiDetectorStateSeries(MultiDetectorStateSeries *mdetStates)
Helper function to get rid of a multi-IFO DetectorStateSeries Note, this is "NULL-robust" in the sens...
int XLALMultiLALDetectorFromMultiSFTs(MultiLALDetector *multiIFO, const MultiSFTVector *multiSFTs)
Extract multi detector-info from a given multi SFTCatalog view.
MultiDetectorStateSeries * XLALGetMultiDetectorStates(const MultiLIGOTimeGPSVector *multiTS, const MultiLALDetector *multiIFO, const EphemerisData *edat, REAL8 tOffset)
Get the detector-time series for the given MultiLIGOTimeGPSVector.
void XLALDestroyMultiREAL8TimeSeries(MultiREAL8TimeSeries *multiTS)
Destroy a MultiREAL8TimeSeries, NULL-robust.
EphemerisData * XLALInitBarycenter(const CHAR *earthEphemerisFile, const CHAR *sunEphemerisFile)
XLAL interface to reading ephemeris files 'earth' and 'sun', and return ephemeris-data in old backwar...
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
void XLALDestroyMultiAMCoeffs(MultiAMCoeffs *multiAMcoef)
Destroy a MultiAMCoeffs structure.
Definition: LALComputeAM.c:469
MultiAMCoeffs * XLALComputeMultiAMCoeffs(const MultiDetectorStateSeries *multiDetStates, const MultiNoiseWeights *multiWeights, SkyPosition skypos)
Multi-IFO version of XLALComputeAMCoeffs().
Definition: LALComputeAM.c:379
#define LAL_DAYSID_SI
#define LAL_YRSID_SI
#define LAL_TWOPI
unsigned char BOOLEAN
#define XLAL_INIT_MEM(x)
uint64_t UINT8
double REAL8
#define XLAL_INIT_DECL(var,...)
char CHAR
uint32_t UINT4
float complex COMPLEX8
int32_t INT4
LALNameLength
void * XLALCalloc(size_t m, size_t n)
void * XLALRealloc(void *p, size_t n)
void XLALFree(void *p)
#define LAL_REAL8_FORMAT
#define LAL_INT4_FORMAT
#define LAL_UINT8_FORMAT
#define LAL_UINT4_FORMAT
char char * XLALStringDuplicate(const char *s)
char * XLALStringToken(char **s, const char *delim, int empty)
char * XLALVCSInfoString(const LALVCSInfoList vcs_list, const int verbose, const char *prefix)
int XLALSetLatticeTilingConstantBound(LatticeTiling *tiling, const size_t dim, const double bound1, const double bound2)
Set a constant lattice tiling parameter-space bound, given by the minimum and maximum of the two supp...
int XLALSetTilingLatticeAndMetric(LatticeTiling *tiling, const TilingLattice lattice, const gsl_matrix *metric, const double max_mismatch)
Set the tiling lattice, parameter-space metric, and maximum prescribed mismatch.
LatticeTilingIterator * XLALCreateLatticeTilingIterator(const LatticeTiling *tiling, const size_t itr_ndim)
Create a new lattice tiling iterator.
void XLALDestroyLatticeTilingIterator(LatticeTilingIterator *itr)
Destroy a lattice tiling iterator.
void XLALDestroyLatticeTiling(LatticeTiling *tiling)
Destroy a lattice tiling.
int XLALNextLatticeTilingPoint(LatticeTilingIterator *itr, gsl_vector *point)
Advance lattice tiling iterator, and optionally return the next point in point.
LatticeTiling * XLALCreateLatticeTiling(const size_t ndim)
Create a new lattice tiling.
const UserChoices TilingLatticeChoices
Static array of all :tagTilingLattice choices, for use by the UserInput module parsing routines.
@ TILING_LATTICE_ANSTAR
An-star ( ) lattice.
Definition: LatticeTiling.h:65
REAL8 XLALGetTimeOfDay(void)
void LogPrintf(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
LOG_CRITICAL
MultiPSDVector * XLALNormalizeMultiSFTVect(MultiSFTVector *multsft, UINT4 blockSize, const MultiNoiseFloor *assumeSqrtSX)
Function for normalizing a multi vector of SFTs in a multi IFO search and returns the running-median ...
void XLALDestroyMultiPSDVector(MultiPSDVector *multvect)
Destroy a multi PSD-vector.
Definition: PSDutils.c:102
MultiNoiseWeights * XLALComputeMultiNoiseWeights(const MultiPSDVector *rngmed, UINT4 blocksRngMed, UINT4 excludePercentile)
Computes weight factors arising from MultiSFTs with different noise floors.
Definition: PSDutils.c:285
void XLALDestroyMultiNoiseWeights(MultiNoiseWeights *weights)
Destroy a MultiNoiseWeights object.
Definition: PSDutils.c:172
void XLALDestroySFTPairIndexList(SFTPairIndexList *sftPairs)
Destroy a SFTPairIndexList structure.
void XLALDestroyResampCrossCorrWorkspace(void *workspace)
int XLALCreateCrossCorrWorkspace(ResampCrossCorrWorkspace **wsOut, COMPLEX8 **ws1KFaX_kOut, COMPLEX8 **ws1KFbX_kOut, COMPLEX8 **ws2LFaX_kOut, COMPLEX8 **ws2LFbX_kOut, MultiCOMPLEX8TimeSeries **multiTimeSeries_SRC_aOut, MultiCOMPLEX8TimeSeries **multiTimeSeries_SRC_bOut, const PulsarDopplerParams binaryTemplateSpacings, FstatInput *resampFstatInput, const UINT4 numFreqBins, const REAL8 tCoh, const BOOLEAN treatWarningsAsErrors)
‍** (possible future function) does not work – would adjust timestamps of an SFT vector *‍/
MultiLIGOTimeGPSVector * XLALGenerateMultiTshortTimestamps(const MultiLIGOTimeGPSVector *restrict multiTimes, const REAL8 tShort, const UINT4 numShortPerDet, const BOOLEAN alignTShorts)
Given a multi-SFT vector, return a MultiLIGOTimeGPSVector holding the modified SFT timestamps (produc...
int XLALCalculateCrossCorrPhaseDerivatives(REAL8VectorSequence **phaseDerivs, const PulsarDopplerParams *dopplerPoint, const EphemerisData *edat, SFTIndexList *indexList, MultiSSBtimes *multiTimes, const DopplerCoordinateSystem *coordSys)
calculate signal phase derivatives wrt Doppler coords, for each SFT
int XLALCreateSFTPairIndexList(SFTPairIndexList **pairIndexList, SFTIndexList *indexList, MultiSFTVector *sfts, REAL8 maxLag, BOOLEAN inclAutoCorr)
Construct list of SFT pairs for inclusion in statistic.
int XLALCalculateLMXBCrossCorrDiagMetric(REAL8 *hSens, REAL8 *g_ff, REAL8 *g_aa, REAL8 *g_TT, REAL8 *g_pp, REAL8 *weightedMuTAve, PulsarDopplerParams DopplerParams, REAL8Vector *G_alpha, SFTPairIndexList *pairIndexList, SFTIndexList *indexList, MultiSFTVector *sfts, MultiNoiseWeights *multiWeights)
int XLALCalculateCrossCorrGammasResampShort(REAL8Vector **Gamma_ave, REAL8Vector **Gamma_circ, MultiResampSFTPairMultiIndexList *resampMultiPairIndexList, MultiAMCoeffs *multiCoeffs)
test function for RESAMPLING with tShort
MultiNoiseWeights * XLALModifyMultiWeights(const MultiNoiseWeights *restrict multiWeights, const REAL8 tShort, const REAL8 tSFTOld, const UINT4 numShortPerDet, const MultiLIGOTimeGPSVector *restrict multiTimes)
Modify multiple detectors' amplitude weight coefficients for tShort.
int XLALCalculateCrossCorrGammas(REAL8Vector **Gamma_ave, REAL8Vector **Gamma_circ, SFTPairIndexList *pairIndexList, SFTIndexList *indexList, MultiAMCoeffs *multiCoeffs)
Construct vector of G_alpha amplitudes for each SFT pair.
int XLALCalculatePulsarCrossCorrStatisticResamp(REAL8Vector *restrict ccStatVector, REAL8Vector *restrict evSquaredVector, REAL8Vector *restrict numeEquivAve, REAL8Vector *restrict numeEquivCirc, const REAL8Vector *restrict resampCurlyGAmp, const MultiResampSFTPairMultiIndexList *restrict resampMultiPairs, const MultiNoiseWeights *restrict multiWeights, const PulsarDopplerParams *restrict binaryTemplateSpacings, const PulsarDopplerParams *restrict dopplerpos, const MultiCOMPLEX8TimeSeries *restrict multiTimeSeries_SRC_a, const MultiCOMPLEX8TimeSeries *restrict multiTimeSeries_SRC_b, ResampCrossCorrWorkspace *restrict ws, COMPLEX8 *restrict ws1KFaX_k, COMPLEX8 *restrict ws1KFbX_k, COMPLEX8 *restrict ws2LFaX_k, COMPLEX8 *restrict ws2LFbX_k)
Calculate multi-bin cross-correlation statistic using resampling.
int XLALCreateSFTPairIndexListAccurateResamp(SFTPairIndexList **pairIndexList, UINT4VectorSequence **sftPairForTshortPair, SFTIndexList *indexList, MultiResampSFTPairMultiIndexList *resampPairs, const MultiLIGOTimeGPSVector *restrict multiTimes, const MultiLIGOTimeGPSVector *restrict resampMultiTimes)
Construct list of SFT pairs corresponding to a list of tShort pairs.
int XLALCreateSFTPairIndexListResamp(MultiResampSFTPairMultiIndexList **resampMultiPairIndexList, SFTPairIndexList **pairIndexList, SFTIndexList *indexList, MultiSFTVector *sfts, REAL8 maxLag, BOOLEAN inclAutoCorr, BOOLEAN inclSameDetector, REAL8 Tsft, REAL8 Tshort)
Resampling-modified: construct list of SFT pairs for inclusion in statistic.
MultiAMCoeffs * XLALComputeMultiAMCoeffsShort(const MultiDetectorStateSeries *multiDetStates, const MultiNoiseWeights *multiWeights, SkyPosition skypos, REAL8 tShort, REAL8 tSFTOld, UINT4 numShortPerDet, MultiLIGOTimeGPSVector *multiTimes)
(test function) used for computing multi amplitude modulation weights
int XLALCalculateCrossCorrPhaseMetricShort(gsl_matrix **g_ij, gsl_vector **eps_i, REAL8 *sumGammaSq, const REAL8VectorSequence *phaseDerivs, const MultiResampSFTPairMultiIndexList *resampMultiPairs, const REAL8Vector *Gamma_ave, const REAL8Vector *Gamma_circ, const DopplerCoordinateSystem *coordSys)
(test function) Redesigning to use Tshort instead
int XLALCalculatePulsarCrossCorrStatistic(REAL8 *ccStat, REAL8 *evSquared, REAL8Vector *curlyGAmp, COMPLEX8Vector *expSignalPhases, UINT4Vector *lowestBins, REAL8VectorSequence *sincList, SFTPairIndexList *sftPairs, SFTIndexList *sftIndices, MultiSFTVector *inputSFTs, MultiNoiseWeights *multiWeights, UINT4 numBins)
Calculate multi-bin cross-correlation statistic.
void XLALDestroySFTIndexList(SFTIndexList *sftIndices)
Destroy a SFTIndexList structure.
void XLALDestroyMultiResampSFTPairMultiIndexList(MultiResampSFTPairMultiIndexList *sftMultiPairsResamp)
int XLALCombineCrossCorrGammas(REAL8Vector **resampGamma, REAL8Vector *Gamma, UINT4VectorSequence *sftPairForTshortPair, REAL8 Tsft, REAL8 Tshort)
Combine G_alpha amplitudes for SFT pairs into amplitudes for Tshort pairs.
int XLALCreateSFTIndexListFromMultiSFTVect(SFTIndexList **indexList, MultiSFTVector *sfts)
Construct flat SFTIndexList out of a MultiSFTVector.
int XLALGetDopplerShiftedFrequencyInfo(REAL8Vector *shiftedFreqs, UINT4Vector *lowestBins, COMPLEX8Vector *expSignalPhases, REAL8VectorSequence *sincList, UINT4 numBins, PulsarDopplerParams *dopp, SFTIndexList *sftIndices, MultiSFTVector *inputSFTs, MultiSSBtimes *multiTimes, MultiUINT4Vector *badBins, REAL8 Tsft)
Calculate the Doppler-shifted frequency associated with each SFT in a list.
int XLALCalculateCrossCorrGammasResamp(REAL8Vector **Gamma_ave, REAL8Vector **Gamma_circ, MultiResampSFTPairMultiIndexList *resampMultiPairIndexList, MultiAMCoeffs *multiCoeffs)
test function for RESAMPLING
int XLALCalculateCrossCorrPhaseMetric(gsl_matrix **g_ij, gsl_vector **eps_i, REAL8 *sumGammaSq, const REAL8VectorSequence *phaseDerivs, const SFTPairIndexList *pairIndexList, const REAL8Vector *Gamma_ave, const REAL8Vector *Gamma_circ, const DopplerCoordinateSystem *coordSys)
calculate phase metric for CW cross-correlation search, as well as vector used for parameter offsets
MultiLIGOTimeGPSVector * XLALExtractMultiTimestampsFromSFTsShort(MultiREAL8TimeSeries **scienceFlagVect, const MultiSFTVector *multiSFTs, REAL8 tShort, UINT4 numShortPerDet)
Given a multi-SFT vector, return a MultiLIGOTimeGPSVector holding the SFT timestamps (test function u...
int XLALCalculateLMXBCrossCorrDiagMetricShort(REAL8 *hSens, REAL8 *g_ff, REAL8 *g_aa, REAL8 *g_TT, REAL8 *g_pp, const PulsarDopplerParams DopplerParams, const REAL8Vector *restrict G_alpha, const MultiResampSFTPairMultiIndexList *restrict resampMultiPairIndexList, const MultiLIGOTimeGPSVector *restrict timestamps, const MultiNoiseWeights *restrict multiWeights)
MODIFIED for Tshort: calculate metric diagonal components, also include the estimation of sensitivity...
UINT4 XLALCrossCorrNumShortPerDetector(const REAL8 resampTshort, const INT4 startTime, const INT4 endTime)
Compute the number of tShort segments per detector.
int XLALCreateSFTPairIndexListShortResamp(MultiResampSFTPairMultiIndexList **resampMultiPairIndexList, const REAL8 maxLag, const BOOLEAN inclAutoCorr, const BOOLEAN inclSameDetector, const REAL8 Tsft, const MultiLIGOTimeGPSVector *restrict multiTimes)
With Tshort, and Resampling-modified: construct list of SFT pairs for inclusion in statistic.
MultiDetectorStateSeries * XLALGetMultiDetectorStatesShort(const MultiLIGOTimeGPSVector *multiTS, const MultiLALDetector *multiIFO, const EphemerisData *edat, REAL8 tOffset, REAL8 tShort, UINT4 numShortPerDet)
(test function) get multi detector states for tShort
int XLALCalculateCrossCorrPhaseDerivativesShort(REAL8VectorSequence **resampPhaseDerivs, const PulsarDopplerParams *dopplerPoint, const EphemerisData *edat, SFTIndexList *indexList, MultiResampSFTPairMultiIndexList *resampMultiPairs, MultiSSBtimes *multiTimes, const DopplerCoordinateSystem *coordSys)
(test function) MODIFIED for Tshort
#define PULSAR_MAX_SPINS
maximal number of spin-parameters (Freq + spindowns) we can handle
static const INT4 m
void XLALDestroySFTCatalog(SFTCatalog *catalog)
Free an 'SFT-catalogue'.
Definition: SFTcatalog.c:329
MultiSFTVector * XLALLoadMultiSFTs(const SFTCatalog *inputCatalog, REAL8 fMin, REAL8 fMax)
Function to load a catalog of SFTs from possibly different detectors.
Definition: SFTfileIO.c:416
void XLALDestroyMultiSFTVector(MultiSFTVector *multvect)
Destroy a multi SFT-vector.
Definition: SFTtypes.c:424
SFTCatalog * XLALSFTdataFind(const CHAR *file_pattern, const SFTConstraints *constraints)
Find the list of SFTs matching the file_pattern and satisfying the given constraints,...
Definition: SFTcatalog.c:71
MultiLIGOTimeGPSVector * XLALExtractMultiTimestampsFromSFTs(const MultiSFTVector *multiSFTs)
Given a multi-SFT vector, return a MultiLIGOTimeGPSVector holding the SFT timestamps.
int XLALMultiSFTVectorAdd(MultiSFTVector *a, const MultiSFTVector *b)
Adds SFT-data from MultiSFTvector 'b' to elements of MultiSFTVector 'a'.
Definition: SFTtypes.c:842
void XLALDestroyMultiTimestamps(MultiLIGOTimeGPSVector *multiTS)
Destroy a MultiLIGOTimeGPSVector timestamps vector.
MultiSSBtimes * XLALGetMultiSSBtimes(const MultiDetectorStateSeries *multiDetStates, SkyPosition skypos, LIGOTimeGPS refTime, SSBprecision precision)
Multi-IFO version of XLALGetSSBtimes().
Definition: SSBtimes.c:657
void XLALDestroyMultiSSBtimes(MultiSSBtimes *multiSSB)
Destroy a MultiSSBtimes structure.
Definition: SSBtimes.c:845
int XLALAddMultiBinaryTimes(MultiSSBtimes **multiSSBOut, const MultiSSBtimes *multiSSBIn, const PulsarDopplerParams *Doppler)
Multi-IFO version of XLALAddBinaryTimes().
Definition: SSBtimes.c:413
MultiSSBtimes * XLALDuplicateMultiSSBtimes(const MultiSSBtimes *multiSSB)
Duplicate (ie allocate + copy) an input MultiSSBtimes structure.
Definition: SSBtimes.c:487
@ SSBPREC_RELATIVISTICOPT
optimized relativistic, numerically equivalent to SSBPREC_RELATIVISTIC, but faster
Definition: SSBtimes.h:48
COORDINATESYSTEM_EQUATORIAL
void XLALDestroyStringVector(LALStringVector *vect)
LALStringVector * XLALAppendString2Vector(LALStringVector *vect, const CHAR *string)
@ DOPPLERCOORD_TASC
Time of ascension (neutron star crosses line of nodes moving away from observer) for binary orbit (EL...
@ DOPPLERCOORD_ASINI
Projected semimajor axis of binary orbit in small-eccentricy limit (ELL1 model) [Units: light seconds...
@ DOPPLERCOORD_PORB
Period of binary orbit (ELL1 model) [Units: s].
@ DOPPLERCOORD_FREQ
Frequency [Units: Hz].
int XLALUserVarReadAllInput(BOOLEAN *should_exit, int argc, char *argv[], const LALVCSInfoList vcs_list)
void XLALDestroyUserVars(void)
#define XLALRegisterUvarMember(name, type, option, category,...)
void CHAR * XLALUserVarGetLog(UserVarLogFormat format)
int XLALUserVarWasSet(const void *cvar)
#define XLALRegisterUvarAuxDataMember(name, type, cdata, option, category,...)
UVAR_LOGFMT_CFGFILE
void XLALDestroyUINT4Vector(UINT4Vector *vector)
COMPLEX8Vector * XLALCreateCOMPLEX8Vector(UINT4 length)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
UINT4Vector * XLALCreateUINT4Vector(UINT4 length)
void XLALDestroyCHARVector(CHARVector *vector)
CHARVector * XLALCreateCHARVector(UINT4 length)
void XLALDestroyCOMPLEX8Vector(COMPLEX8Vector *vector)
void XLALDestroyCHARVectorSequence(CHARVectorSequence *vecseq)
CHARVectorSequence * XLALCreateCHARVectorSequence(UINT4 length, UINT4 veclen)
#define xlalErrno
#define XLAL_ERROR(...)
#define XLAL_CHECK(assertion,...)
#define XLAL_CHECK_MAIN(assertion,...)
int XLALPrintError(const char *fmt,...) _LAL_GCC_PRINTF_FORMAT_(1
XLAL_ENOMEM
XLAL_SUCCESS
XLAL_EFUNC
XLAL_ETYPE
XLAL_EINVAL
XLAL_EFAILED
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
LIGOTimeGPS * XLALGPSSet(LIGOTimeGPS *epoch, INT4 gpssec, INT8 gpsnan)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
long long count
Definition: hwinject.c:371
n
int deltaF
fStart
#define MYMIN(x, y)
#define PCC_LINEFILE_HEADER
#define MAXLINELENGTH
int testShortFunctionsBlock(UserInput_t uvar, MultiSFTVector *inputSFTs, REAL8 Tsft, REAL8 resampTshort, SFTIndexList **sftIndices, SFTPairIndexList **sftPairs, REAL8Vector **GammaAve, REAL8Vector **GammaCirc, MultiResampSFTPairMultiIndexList **resampMultiPairs, MultiLALDetector *multiDetectors, MultiDetectorStateSeries **multiStates, MultiDetectorStateSeries **resampMultiStates, MultiNoiseWeights **multiWeights, MultiLIGOTimeGPSVector **multiTimes, MultiLIGOTimeGPSVector **resampMultiTimes, MultiSSBtimes **multiSSBTimes, REAL8VectorSequence **phaseDerivs, gsl_matrix **g_ij, gsl_vector **eps_i, REAL8 estSens, SkyPosition *skypos, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *thisBinaryTemplate, ConfigVariables config, const DopplerCoordinateSystem coordSys)
int main(int argc, char *argv[])
int demodLoopCrossCorr(MultiSSBtimes *multiBinaryTimes, MultiSSBtimes *multiSSBTimes, PulsarDopplerParams dopplerpos, BOOLEAN dopplerShiftFlag, PulsarDopplerParams binaryTemplateSpacings, PulsarDopplerParams minBinaryTemplate, PulsarDopplerParams maxBinaryTemplate, UINT8 fCount, UINT8 aCount, UINT8 tCount, UINT8 pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, REAL8Vector *shiftedFreqs, UINT4Vector *lowestBins, COMPLEX8Vector *expSignalPhases, REAL8VectorSequence *sincList, UserInput_t uvar, SFTIndexList *sftIndices, MultiSFTVector *inputSFTs, MultiUINT4Vector *badBins, REAL8 Tsft, MultiNoiseWeights *multiWeights, REAL8 ccStat, REAL8 evSquared, REAL8 estSens, REAL8Vector *GammaAve, SFTPairIndexList *sftPairs, CrossCorrBinaryOutputEntry thisCandidate, toplist_t *ccToplist, int DEMODndim, int DEMODdimf, int DEMODdima, int DEMODdimT, int DEMODdimP, gsl_matrix *metric_ij, int *DEMODnumpoints, int *DEMODnumorb, ConfigVariables *config)
Function to isolate the loop for demod.
#define PCC_LINEFILE_BODY
#define PCC_GAMMA_BODY
UINT4 pcc_count_csv(CHAR *csvline)
Counts the number of comma separated values in a string.
int GetNextCrossCorrTemplateForResamp(BOOLEAN *binaryParamsFlag, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *binaryTemplateSpacings, PulsarDopplerParams *minBinaryTemplate, PulsarDopplerParams *maxBinaryTemplate, UINT8 *fCount, UINT8 *aCount, UINT8 *tCount, UINT8 *pCount, ConfigVariables *config)
#define MYMAX(x, y)
int resampForLoopCrossCorr(PulsarDopplerParams dopplerpos, BOOLEAN dopplerShiftGlag, PulsarDopplerParams binaryTemplateSpacings, PulsarDopplerParams minBinaryTemplate, PulsarDopplerParams maxBinaryTemplate, UINT8 fCount, UINT8 aCount, UINT8 tCount, UINT8 pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, UserInput_t uvar, MultiNoiseWeights *multiWeights, UINT4 *numSamplesFFT, REAL8Vector *ccStatVector, REAL8Vector *evSquaredVector, REAL8Vector *numeEquivAve, REAL8Vector *numeEquivCirc, REAL8 estSens, REAL8Vector *resampGammaAve, MultiResampSFTPairMultiIndexList *resampMultiPairs, CrossCorrBinaryOutputEntry thisCandidate, toplist_t *ccToplist, REAL8 tShort, ConfigVariables *config)
For-loop function for resampling.
#define PCC_GAMMA_HEADER
INT4 XLALFindBadBins(UINT4Vector *badBinData, INT4 binCount, REAL8 flo, REAL8 fhi, REAL8 f0, REAL8 deltaF, UINT4 length)
Convert a range of contaminated frequencies into a set of bins to zero out.
#define SQR(x)
#define TRUE
#define FALSE
#define PCC_SFTPAIR_BODY
int XLALDestroyConfigVars(ConfigVariables *config)
#define PCC_SFT_BODY
#define MAXFILENAMELENGTH
#define PCC_SFT_HEADER
int XLALInitializeConfigVars(ConfigVariables *config, const UserInput_t *uvar)
int XLALInitUserVars(UserInput_t *uvar)
Register all our "user-variables" that can be specified from cmd-line and/or config-file.
int GetNextCrossCorrTemplate(BOOLEAN *binaryParamsFlag, BOOLEAN *firstPoint, PulsarDopplerParams *dopplerpos, PulsarDopplerParams *binaryTemplateSpacings, PulsarDopplerParams *minBinaryTemplate, PulsarDopplerParams *maxBinaryTemplate, UINT8 *fCount, UINT8 *aCount, UINT8 *tCount, UINT8 *pCount, UINT8 fSpacingNum, UINT8 aSpacingNum, UINT8 tSpacingNum, UINT8 pSpacingNum, ConfigVariables *config)
FIXME: spacings and min, max values of binary parameters are not used yet.
#define PCC_SFTPAIR_HEADER
CHAR * data
CHAR name[LALNameLength]
COMPLEX8Sequence * data
COMPLEX8FrequencySeries * data
Pointer to the data array.
Struct controlling all the aspects of the fake data (time-series + SFTs) to be produced by XLALCWMake...
Configuration settings required for and defining a coherent pulsar search.
REAL8 mismatchMaxP
maximum mismatch in porb
REAL8 refTime
reference time for pulsar phase definition
REAL8 dPorbdTascShear
slope of centerline of prior ellipse
SFTCatalog * catalog
catalog of SFTs
BOOLEAN useTPEllipse
whether to use elliptical boundary for Tasc-Porb search space
int norb
number of orbits to shift prior elliptical boundary for Tasc-Porb search space
REAL8 mismatchMaxThreeD
mismatch used for 3d lattice
REAL8 unshearedgTT
metric element gTT in unsheared coordinates
REAL8 unshearedgTP
metric element gTP in unsheared coordinates
REAL8 orbitPSecMax
maximum binary orbital period in seconds
REAL8 orbitPSecMin
minimum binary orbital period in seconds
REAL8 orbitTimeAscCenterShifted
shifted center of prior ellipse for binary time of ascension (GPS seconds)
EphemerisData * edat
ephemeris data
LALStringVector * lineFiles
list of line files
Type to hold the fields that will be kept in a "toplist" – for a directed binary search.
REAL8 ecc
eccentricity
REAL8 argp
argument of periapse
REAL8 estSens
average template E[rho]/h0^2)^2
REAL8 period
bperiod
REAL8 evSquared
E[rho]/h0^2)^2.
REAL8 tp
time of periapse passage
REAL8 rho
Crosscorr statistic.
REAL8 freq
Frequency.
REAL8 asini
projected semi-major axis
type describing a Doppler coordinate system: lists the number of dimensions and the symbolic names of...
UINT4 dim
number of dimensions covered
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
Struct of optional 'advanced level' and (potentially method-specific) arguments to be passed to the ...
Definition: ComputeFstat.h:137
MultiNoiseFloor * injectSqrtSX
Single-sided PSD values for fake Gaussian noise to be added to SFT data.
Definition: ComputeFstat.h:144
PulsarParamsVector * injectSources
Vector of parameters of CW signals to simulate and inject.
Definition: ComputeFstat.h:143
UINT4 runningMedianWindow
If SFT noise weights are calculated from the SFTs, the running median window length to use.
Definition: ComputeFstat.h:141
BOOLEAN resampFFTPowerOf2
Resamp: round up FFT lengths to next power of 2; see FstatMethodType.
Definition: ComputeFstat.h:148
REAL8 allowedMismatchFromSFTLength
Optional override for XLALFstatCheckSFTLengthMismatch().
Definition: ComputeFstat.h:149
UINT4 Dterms
Number of Dirichlet kernel terms, used by some Demod methods; see FstatMethodType.
Definition: ComputeFstat.h:140
FstatMethodType FstatMethod
Method to use for computing the -statistic.
Definition: ComputeFstat.h:142
XLALComputeFstat() computed results structure.
Definition: ComputeFstat.h:202
INT4 gpsNanoSeconds
LIGOTimeGPS * data
array of timestamps
Definition: SFTfileIO.h:193
Multi-IFO container for antenna-pattern coefficients and atenna-pattern matrix .
Definition: LALComputeAM.h:137
Multi-IFO container for COMPLEX8 resampled timeseries.
Definition: LFTandTSutils.h:52
Multi-IFO time-series of DetectorStates.
array of detectors definitions 'LALDetector'
UINT4 length
number of detectors
A collection of (multi-IFO) LIGOTimeGPSVector time-stamps vectors.
Definition: SFTfileIO.h:198
UINT4 length
number of timestamps vectors or ifos
Definition: SFTfileIO.h:202
LIGOTimeGPSVector ** data
timestamps vector for each ifo
Definition: SFTfileIO.h:203
array of detector-specific 'noise floors' (ie PSD values), assumed constant over the frequency-band o...
One noise-weight (number) per SFT (therefore indexed over IFOs and SFTs.
Definition: PSDutils.h:71
REAL8 Sinv_Tsft
normalization factor used: (using single-sided PSD!)
Definition: PSDutils.h:77
A collection of PSD vectors – one for each IFO in a multi-IFO search.
Definition: PSDutils.h:62
A collection of (multi-IFO) REAL8 time-series.
Resampling Multi List of all paired SFTs L_Y_K_X, top level (multiple pairs, multiple detectors)
REAL8 maxLag
Maximum allowed lag time.
SFTPairIndexList * pairIndexList
Make a classic pair index list.
SFTIndexList * indexList
Make an overall flat index list.
A collection of SFT vectors – one for each IFO in a multi-IFO search.
Definition: SFTfileIO.h:179
UINT4 length
number of ifos
Definition: SFTfileIO.h:183
SFTVector ** data
sftvector for each ifo
Definition: SFTfileIO.h:184
Multi-IFO container for SSB timings.
Definition: SSBtimes.h:67
A collection of UINT4Vectors – one for each IFO
UINT4Vector ** data
unit4vector for each ifo
UINT4 length
number of ifos
Type containing the 'Doppler-parameters' affecting the time-evolution of the phase.
REAL8 period
Binary: orbital period (sec)
LIGOTimeGPS tp
Binary: time of observed periapsis passage (in SSB)
PulsarSpins fkdot
Intrinsic spins: [Freq, f1dot, f2dot, ... ] where fkdot = d^kFreq/dt^k.
REAL8 ecc
Binary: orbital eccentricity.
REAL8 asini
Binary: projected, normalized orbital semi-major axis (s).
REAL8 argp
Binary: argument of periapsis (radians)
Straightforward vector type of N PulsarParams structs.
REAL8 * data
UINT4 numSamplesFFT
allocated number of zero-padded SRC-frame time samples (related to dFreq)
An "SFT-catalogue": a vector of SFTdescriptors, as returned by XLALSFTdataFind()
Definition: SFTfileIO.h:238
SFTDescriptor * data
array of data-entries describing matched SFTs
Definition: SFTfileIO.h:243
'Constraints' for SFT-matching: which detector, within which time-stretch and which timestamps exactl...
Definition: SFTfileIO.h:212
CHAR * detector
2-char channel-prefix describing the detector (eg 'H1', 'H2', 'L1', 'G1' etc)
Definition: SFTfileIO.h:213
LIGOTimeGPSVector * timestamps
list of timestamps
Definition: SFTfileIO.h:216
LIGOTimeGPS * maxStartTime
only include SFTs whose epoch is < maxStartTime
Definition: SFTfileIO.h:215
LIGOTimeGPS * minStartTime
only include SFTs whose epoch is >= minStartTime
Definition: SFTfileIO.h:214
SFTtype header
SFT-header info.
Definition: SFTfileIO.h:228
UINT4 sftInd
index of SFT in list for this detector
UINT4 detInd
index of detector in list
List of SFT indices.
UINT4 length
number of SFTs
SFTIndex * data
array of SFT indices
UINT4 sftNum[2]
ordinal numbers of first and second SFTs
List of SFT pair indices.
UINT4 length
number of SFT Pairs
SFTPairIndex * data
array of SFT Pair indices
UINT4 * data