22 #ifndef _PULSARCROSSCORRV2_H
23 #define _PULSARCROSSCORRV2_H
39 #include <sys/types.h>
51 #include <lal/AVFactories.h>
53 #include <lal/DetectorSite.h>
54 #include <lal/LALDatatypes.h>
55 #include <lal/LALHough.h>
56 #include <lal/RngMedBias.h>
57 #include <lal/LALRunningMedian.h>
58 #include <lal/Velocity.h>
59 #include <lal/Statistics.h>
60 #include <lal/ComputeFstat.h>
61 #include <lal/LALConstants.h>
62 #include <lal/SFTfileIO.h>
63 #include <lal/NormalizeSFTRngMed.h>
64 #include <lal/LALInitBarycenter.h>
65 #include <lal/SFTClean.h>
66 #include <gsl/gsl_cdf.h>
67 #include <gsl/gsl_sf_trig.h>
68 #include <lal/FrequencySeries.h>
69 #include <lal/Sequence.h>
70 #include <lal/SinCosLUT.h>
71 #include <lal/LogPrintf.h>
72 #include <lal/UniversalDopplerMetric.h>
73 #include <lal/ExtrapolatePulsarSpins.h>
74 #include <lal/TimeSeries.h>
75 #include <lal/Units.h>
76 #include <lal/FFTWMutex.h>
86 typedef struct tagSFTIndex {
92 typedef struct tagSFTIndexList {
98 typedef struct tagSFTPairIndex {
107 typedef struct tagSFTPairIndexList {
114 typedef struct tagSFTCount {
124 typedef struct tagResampSFTMultiCountList {
131 typedef struct tagResampSFTMultiCountListDet {
138 typedef struct tagMultiResampSFTMultiCountList {
145 typedef struct tagResampSFTIndex {
154 typedef struct tagResampSFTIndexList {
161 typedef struct tagResampSFTMultiIndexList {
170 typedef struct tagResampSFTPairMultiIndexList {
178 typedef struct tagMultiResampSFTPairIndexMultiList {
195 typedef struct tagCrossCorrTimings_t {
208 typedef struct tagResampCrossCorrTimingInfo {
222 typedef struct tagResampCrossCorrWorkspace {
250 typedef struct tagMultiUINT4Vector {
314 const BOOLEAN inclSameDetector,
444 REAL8 *weightedMuTAve,
488 const UINT4 numShortPerDet
504 const UINT4 numShortPerDet
548 const UINT4 numShortPerDet,
550 const UINT4 maxNumStepsOldIfGapless,
562 const UINT4 numShortPerDet,
573 UINT4 numShortPerDet,
584 UINT4 numShortPerDet,
597 const REAL8 resampTshort,
636 FstatInput *resampFstatInput,
637 const UINT4 numFreqBins,
639 const BOOLEAN treatWarningsAsErrors
LIGOTimeGPSVector * timestamps
int XLALEquipCrossCorrPairsWithScienceFlags(MultiResampSFTPairMultiIndexList *resampMultiPairs, MultiREAL8TimeSeries *scienceFlagVect)
Demarcate pairs with flags about whether data exists in zero-padded timeseries.
void XLALDestroyResampSFTIndexList(ResampSFTIndexList *sftResampList)
int XLALModifyMultiAMCoeffsWeights(MultiNoiseWeights **multiWeights, const REAL8 tShort, const REAL8 tSFTOld, const UINT4 numShortPerDet, const MultiLIGOTimeGPSVector *_LAL_RESTRICT_ multiTimes)
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 */
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 XLALCreateSFTPairIndexListShortResamp(MultiResampSFTPairMultiIndexList **resampPairIndexList, const REAL8 maxLag, const BOOLEAN inclAutoCorr, const BOOLEAN inclSameDetector, const REAL8 Tsft, const MultiLIGOTimeGPSVector *_LAL_RESTRICT_ multiTimes)
AMCoeffs * XLALComputeAMCoeffsShort(const DetectorStateSeries *DetectorStates, SkyPosition skypos)
(test function) used for computing amplitude modulation weights
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
MultiLIGOTimeGPSVector * XLALModifyMultiTimestampsFromSFTs(MultiREAL8TimeSeries **scienceFlagVect, const MultiLIGOTimeGPSVector *_LAL_RESTRICT_ multiTimes, const REAL8 tShort, const UINT4 numShortPerDet)
int XLALFillDetectorTensorShort(DetectorState *detState, const LALDetector *detector)
(test function) fill detector state with tShort, importing various slightly-modified LALPulsar functi...
int XLALWeightMultiAMCoeffsShort(MultiAMCoeffs *multiAMcoef, const MultiNoiseWeights *multiWeights, REAL8 tShort, REAL8 tSFTOld, UINT4 numShortPerDet, MultiLIGOTimeGPSVector *multiTimes)
(test function) used for weighting multi amplitude modulation coefficients
LIGOTimeGPSVector * XLALExtractTimestampsFromSFTsShort(REAL8TimeSeries **sciFlag, const SFTVector *sfts, REAL8 tShort, UINT4 numShortPerDet)
** (possible future function) Wrapper for Bessel Orbital Space stepper in the manner of V....
int XLALCalculateLMXBCrossCorrDiagMetricShort(REAL8 *hSens, REAL8 *g_ff, REAL8 *g_aa, REAL8 *g_TT, REAL8 *g_pp, const PulsarDopplerParams DopplerParams, const REAL8Vector *_LAL_RESTRICT_ G_alpha, const MultiResampSFTPairMultiIndexList *_LAL_RESTRICT_ resampMultiPairIndexList, const MultiLIGOTimeGPSVector *_LAL_RESTRICT_ timestamps, const MultiNoiseWeights *_LAL_RESTRICT_ multiWeights)
int XLALCalculateCrossCorrGammas(REAL8Vector **Gamma_ave, REAL8Vector **Gamma_circ, SFTPairIndexList *pairIndexList, SFTIndexList *indexList, MultiAMCoeffs *multiCoeffs)
Construct vector of G_alpha amplitudes for each SFT pair.
REAL8TimeSeries * XLALCrossCorrGapFinderResamp(LIGOTimeGPSVector *_LAL_RESTRICT_ timestamps, const LIGOTimeGPSVector *_LAL_RESTRICT_ Times)
int XLALTestResampPairIndexList(MultiResampSFTPairMultiIndexList *resampMultiPairIndexList)
Check that the contents of a resampling multi-pair index list are sensible by inspection.
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)
void XLALDestroyResampSFTMultiIndexList(ResampSFTMultiIndexList *sftResampMultiList)
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
void XLALDestroyMultiMatchList(MultiResampSFTMultiCountList *localMultiListOfLmatchingGivenMultiK)
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 XLALCalculatePulsarCrossCorrStatisticResamp(REAL8Vector *_LAL_RESTRICT_ ccStatVector, REAL8Vector *_LAL_RESTRICT_ evSquaredVector, REAL8Vector *_LAL_RESTRICT_ numeEquivAve, REAL8Vector *_LAL_RESTRICT_ numeEquivCirc, const REAL8Vector *_LAL_RESTRICT_ resampCurlyGAmp, const MultiResampSFTPairMultiIndexList *_LAL_RESTRICT_ resampPairs, const MultiNoiseWeights *_LAL_RESTRICT_ multiWeights, const PulsarDopplerParams *_LAL_RESTRICT_ binaryTemplateSpacings, const PulsarDopplerParams *_LAL_RESTRICT_ dopplerpos, const MultiCOMPLEX8TimeSeries *_LAL_RESTRICT_ multiTimeSeries_SRC_a, const MultiCOMPLEX8TimeSeries *_LAL_RESTRICT_ multiTimeSeries_SRC_b, ResampCrossCorrWorkspace *_LAL_RESTRICT_ ws, COMPLEX8 *_LAL_RESTRICT_ ws1KFaX_k, COMPLEX8 *_LAL_RESTRICT_ ws1KFbX_k, COMPLEX8 *_LAL_RESTRICT_ ws2LFaX_k, COMPLEX8 *_LAL_RESTRICT_ ws2LFbX_k)
UINT4 XLALCrossCorrNumShortPerDetector(const REAL8 resampTshort, const INT4 startTime, const INT4 endTime)
Compute the number of tShort segments per detector.
DetectorStateSeries * XLALGetDetectorStatesShort(const LIGOTimeGPSVector *timestamps, const LALDetector *detector, const EphemerisData *edat, REAL8 tOffset, REAL8 tShort, UINT4 numShortPerDet)
(test function) get detector states for tShort
REAL8TimeSeries * XLALCrossCorrGapFinderResampAlt(LIGOTimeGPSVector *_LAL_RESTRICT_ timestamps, const SFTVector *_LAL_RESTRICT_ sfts)
LIGOTimeGPSVector * XLALModifyTimestampsFromSFTsShort(REAL8TimeSeries **sciFlag, const LIGOTimeGPSVector *_LAL_RESTRICT_ Times, const REAL8 tShort, const UINT4 numShortPerDet)
void XLALDestroyResampSFTPairMultiIndexList(ResampSFTPairMultiIndexList *sftResampPairMultiList)
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 XLALModifyAMCoeffsWeights(REAL8Vector **resampMultiWeightsX, const MultiNoiseWeights *_LAL_RESTRICT_ multiWeights, const REAL8 tShort, const REAL8 tSFTOld, const UINT4 numShortPerDet, const MultiLIGOTimeGPSVector *_LAL_RESTRICT_ multiTimes, const UINT4 maxNumStepsOldIfGapless, const UINT4 X)
int XLALCalculateCrossCorrPhaseDerivativesShort(REAL8VectorSequence **resampPhaseDerivs, const PulsarDopplerParams *dopplerPoint, const EphemerisData *edat, SFTIndexList *indexList, MultiResampSFTPairMultiIndexList *resampMultiPairs, MultiSSBtimes *multiTimes, const DopplerCoordinateSystem *coordSys)
(test function) MODIFIED for Tshort
This structure contains the per-SFT (weighted) antenna-pattern functions , with the SFT-index,...
A vector of COMPLEX8FrequencySeries.
REAL8 F1NoBuf
Resampling timing 'constant': Fstat time per template per detector for an 'unbuffered' usage (differe...
REAL8 Norm
time spent normalizing the final Fa,Fb
REAL8 F1Buf
Resampling timing 'constant': Fstat time per template per detector for a 'buffered' case (same skypos...
REAL8 FFT
time spent in FFT
REAL8 Bary
time spent in barycentric resampling
REAL8 Total
total time spent in XLALComputeFstatResamp()
REAL8 Spin
time spent in spindown+frequency correction
REAL8 Mem
time to realloc and memset-0 arrays
REAL8 Fab2F
time to compute Fstat from {Fa,Fb}
REAL8 SumFabX
time to sum_X Fab^X
State-info about position, velocity and LMST of a detector together with corresponding EarthState.
Timeseries of DetectorState's, representing the detector-info at different timestamps.
type describing a Doppler coordinate system: lists the number of dimensions and the symbolic names of...
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
A vector of 'timestamps' of type LIGOTimeGPS.
Multi-IFO container for antenna-pattern coefficients and atenna-pattern matrix .
Multi-IFO container for COMPLEX8 resampled timeseries.
Multi-IFO time-series of DetectorStates.
array of detectors definitions 'LALDetector'
A collection of (multi-IFO) LIGOTimeGPSVector time-stamps vectors.
One noise-weight (number) per SFT (therefore indexed over IFOs and SFTs.
A collection of (multi-IFO) REAL8 time-series.
OUTER List of SFT indices.
ResampSFTMultiCountListDet * data
list per-detectors X
UINT4 length
number of detectors X
Resampling Multi List of all paired SFTs L_Y_K_X, top level (multiple pairs, multiple detectors)
UINT4 oldPairCount
count of sft pairs, old-style
REAL8 Tshort
Duration of resamp Tshort.
REAL8 maxLag
Maximum allowed lag time.
SFTPairIndexList * pairIndexList
Make a classic pair index list.
UINT4 sftTotalCount
count of all sfts
BOOLEAN inclSameDetector
Do we include same detectors?
ResampSFTPairMultiIndexList * data
list per-detector X
UINT4 length
number of detectors X
REAL8 Tsft
Duration of one SFT.
SFTIndexList * indexList
Make an overall flat index list.
UINT4 allPairCount
count of all pairs
BOOLEAN inclAutoCorr
Do we include auto-correlation?
A collection of SFT vectors – one for each IFO in a multi-IFO search.
Multi-IFO container for SSB timings.
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.
UINT4 numSamplesFFT
actual length of FFT, potentially rounded up to power-of-2 for efficiency
UINT4 numFreqBins
number of frequency bins to compute F-stat for
BOOLEAN collectTiming
turn on/off the collection of F-stat-method-specific timing-data (stored in workspace)
UINT4 numSFTs
total number of SFTs used
UINT4 numSamplesFFT0
'original' length of barycentered timeseries to be FFT'ed
UINT4 numDetectors
number of detectors
COMPLEX8 * FabX_Raw
raw full-band FFT result Fa,Fb
COMPLEX8 * Fa_k
properly normalized F_a(f_k) over output bins
COMPLEX8Vector * TStmp2_SRC
can hold a single-detector SRC-frame spindown-corrected timeseries [without zero-padding]
COMPLEX8 * FaX_k
properly normalized F_a^X(f_k) over output bins
REAL8Vector * SRCtimes_DET
holds uniformly-spaced SRC-frame timesteps translated into detector frame [for interpolation]
UINT4 numFreqBinsOut
number of output frequency bins {f_k}
ResampCrossCorrTimingInfo * timingInfo
pointer to storage for collecting timing data (which lives in ResampMethodData)
fftwf_plan fftplan
buffer FFT plan for given numSamplesOut length
COMPLEX8 * TS_FFT
zero-padded, spindown-corr SRC-frame TS
COMPLEX8 * Fb_k
properly normalized F_b(f_k) over output bins
UINT4 numSamplesFFT
allocated number of zero-padded SRC-frame time samples (related to dFreq)
COMPLEX8 * FbX_k
properly normalized F_b^X(f_k) over output bins
UINT4 numFreqBinsAlloc
internal: keep track of allocated length of frequency-arrays
UINT4 decimateFFT
output every n-th frequency bin, with n>1 iff (dFreq > 1/Tspan), and was internally decreased by n
COMPLEX8Vector * TStmp1_SRC
can hold a single-detector SRC-frame spindown-corrected timeseries [without zero-padding]
Resampling: Index to refer to fields of an SFT given a specific index L_Y_K_X.
REAL4 sciFlag
science-or-not value: 1 is science mode, 0 is in a gap
UINT4 detInd
index of detector in list
UINT4 pairInd
index of SFT among overall pairs
UINT4 sftInd
index of SFT in list for this detector L
UINT4 flatInd
index in the flat SFT list
Resampling: List of SFT indices L for a given detector Y_K_X: indexing method is nominally original v...
UINT4 length
number of SFTs
ResampSFTIndex * data
array of SFT indices
UINT4 detInd
original vector index of detector Y
MIDDLE List of SFT indices.
UINT4 length
number of SFTs K_X
UINT4 detInd
original vector index of detector X
ResampSFTMultiCountList * data
array of SFT L_Y indices for given SFT K_X at detector X
INNER List of SFT indices.
UINT4 sftInd
original vector index of sft K
UINT4 length
number of detectors Y
SFTCount * data
arrays of count of SFTs L_Y, at given detector Y, that match each given SFT K_X
Resampling: Multi List of indices of SFT L_Y, for a given sft K_X
ResampSFTIndexList * data
array, per detector, of lists of SFT indices
UINT4 sftInd
original vector index of sft K
UINT4 length
number of detectors Y
UINT4 flatInd
index in the flat SFT list
REAL4 sciFlag
science-or-not value: 1 is science mode, 0 is in a gap
Resampling Multi List of SFT pair indices (L_Y_K), for a given detector X.
UINT4 length
number of K SFTs at detector X
ResampSFTMultiIndexList * data
array of SFT L_Y indices for given SFT K_X at detector X
UINT4 detInd
original vector index of detector X
Resampling Counter of matching SFTs for a given detector Y_K_X matching SFT K_X.
UINT4 sftCount
number of matching SFTs
UINT4 detInd
original vector index of detector Y
Index to refer to an SFT given a set of SFTs from several different detectors.
UINT4 sftInd
index of SFT in list for this detector
UINT4 detInd
index of detector in list
UINT4 length
number of SFTs
SFTIndex * data
array of SFT indices
Index to refer to a pair of SFTs.
List of SFT pair indices.
UINT4 length
number of SFT Pairs
SFTPairIndex * data
array of SFT Pair indices