21 #include <lal/DopplerScan.h>
22 #include <lal/PulsarCrossCorr.h>
23 #include <gsl/gsl_permutation.h>
25 #define SQUARE(x) (x*x)
37 INT4 i,
j, numPairs, initj;
64 thisSFT1 = &( sfttmp->
sft );
68 if ( autoCorrelate ) {
74 for (
j = initj;
j < listLength;
j++ ) {
80 thisSFT2 = &( sfttmp->
sft );
87 sameDet = strcmp( thisSFT1->
name, thisSFT2->
name );
96 if ( detChoice ==
ALL ) {
101 if ( ( sameDet == (
INT4 )detChoice ) && ( fabs( timeDiff ) <= lag ) ) {
104 List1->
data[thisPair] =
i;
105 List2->
data[thisPair++] =
j;
116 if ( numPairs > 0 ) {
119 for (
i = 0;
i < numPairs;
i++ ) {
161 REAL8 re1, re2, im1, im2;
182 re1 = crealf( sft1->
data->
data[bin1] );
183 im1 = cimagf( sft1->
data->
data[bin1] );
184 re2 = crealf( sft2->
data->
data[bin2] );
185 im2 = cimagf( sft2->
data->
data[bin2] );
215 REAL8 vDotn_c, fhat, factor, timeDiff;
237 fhat = dopp->
fkdot[0];
240 factor *= timeDiff /
k;
241 fhat += dopp->
fkdot[
k] * factor;
243 *
out = fhat * ( 1 + vDotn_c );
264 REAL8 rDotn_c, phihat, factor, timeDiff;
265 REAL8 epoch_plus_rdotn;
297 factor *= timeDiff /
k;
298 phihat += dopp->
fkdot[
k - 1] * factor;
358 deltaPhi = phiI - phiJ -
LAL_PI * ( freqI - freqJ ) /
deltaF;
360 re = 0.1 * cos( deltaPhi ) * ( ( beamfnsI.
a * beamfnsJ.
a ) + ( beamfnsI.
b * beamfnsJ.
b ) );
361 im = - 0.1 * sin( deltaPhi ) * ( ( beamfnsI.
a * beamfnsJ.
a ) + ( beamfnsI.
b * beamfnsJ.
b ) );
364 *(
out ) =
crect( re / ( sigmasq ), -im / ( sigmasq ) );
395 REAL8 FplusI, FplusJ, FcrossI, FcrossJ;
396 REAL8 FpIFpJ, FcIFcJ, FpIFcJ, FcIFpJ;
401 deltaPhi = phiI - phiJ -
LAL_PI * ( freqI - freqJ ) /
deltaF;
406 FplusI = ( beamfnsI.
a * cos( 2.0 * ( *psi ) ) ) + ( beamfnsI.
b * sin( 2.0 * ( *psi ) ) );
407 FplusJ = ( beamfnsJ.
a * cos( 2.0 * ( *psi ) ) ) + ( beamfnsJ.
b * sin( 2.0 * ( *psi ) ) );
408 FcrossI = ( beamfnsI.
b * cos( 2.0 * ( *psi ) ) ) - ( beamfnsI.
a * sin( 2.0 * ( *psi ) ) );
409 FcrossJ = ( beamfnsJ.
b * cos( 2.0 * ( *psi ) ) ) - ( beamfnsJ.
a * sin( 2.0 * ( *psi ) ) );;
412 re = 0.25 * ( ( cos( deltaPhi ) * ( FplusI * FplusJ * amplitudes.
Aplussq + FcrossI * FcrossJ * amplitudes.
Acrosssq ) )
413 - ( sin( deltaPhi ) * ( ( FplusI * FcrossJ - FcrossI * FplusJ ) * amplitudes.
AplusAcross ) ) );
416 im = 0.25 * ( -( cos( deltaPhi ) * ( ( FplusI * FcrossJ - FcrossI * FplusJ ) * amplitudes.
AplusAcross ) )
417 - ( sin( deltaPhi ) * ( FplusI * FplusJ * amplitudes.
Aplussq + FcrossI * FcrossJ * amplitudes.
Acrosssq ) ) );
420 *( gplus ) =
crect( 0.25 * cos( deltaPhi ) * FplusI * FplusJ, 0.25 * ( -sin( deltaPhi ) ) * FplusI * FplusJ );
422 *( gcross ) =
crect( 0.25 * cos( deltaPhi ) * FcrossI * FcrossJ, 0.25 * ( -sin( deltaPhi ) ) * FcrossI * FcrossJ );
426 FpIFpJ = 0.5 * ( ( beamfnsI.
a * beamfnsJ.
a ) + ( beamfnsI.
b * beamfnsJ.
b ) );
427 FcIFcJ = 0.5 * ( ( beamfnsI.
a * beamfnsJ.
a ) + ( beamfnsI.
b * beamfnsJ.
b ) );
428 FpIFcJ = 0.5 * ( ( beamfnsI.
a * beamfnsJ.
b ) - ( beamfnsI.
b * beamfnsJ.
a ) );
429 FcIFpJ = 0.5 * ( ( beamfnsJ.
a * beamfnsI.
b ) - ( beamfnsJ.
b * beamfnsI.
a ) );
432 re = 0.25 * ( ( cos( deltaPhi ) *
433 ( ( FpIFpJ * amplitudes.
Aplussq ) + ( FcIFcJ * amplitudes.
Acrosssq ) ) )
434 - ( sin( deltaPhi ) * ( ( FpIFcJ - FcIFpJ ) * amplitudes.
AplusAcross ) ) );
437 im = 0.25 * ( -( cos( deltaPhi ) * ( ( FpIFcJ - FcIFpJ ) * amplitudes.
AplusAcross ) )
438 - ( sin( deltaPhi ) *
439 ( ( FpIFpJ * amplitudes.
Aplussq ) + ( FcIFcJ * amplitudes.
Acrosssq ) ) ) );
445 *(
out ) =
crect( re / ( sigmasq ), -im / ( sigmasq ) );
477 *
out += 2.0 * ( ( creal( yalpha->
data[
i] ) * creal( ualpha->
data[
i] ) ) - ( cimag( yalpha->
data[
i] ) * cimag( ualpha->
data[
i] ) ) );
534 REAL8 ap1 = 0, ap2 = 0, ac1 = 0, ac2 = 0;
547 ap2 += 2.0 * ( ( creal( yalpha->
data[
i] ) * creal( gplus->
data[
i] ) ) + ( cimag( yalpha->
data[
i] ) * cimag( gplus->
data[
i] ) ) ) / sigmaAlphasq->
data[
i];
548 ac2 += 2.0 * ( ( creal( yalpha->
data[
i] ) * creal( gcross->
data[
i] ) ) + ( cimag( yalpha->
data[
i] ) * cimag( gcross->
data[
i] ) ) ) / sigmaAlphasq->
data[
i];
static double double delta
#define ABORT(statusptr, code, mesg)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
INT4VectorSequence * XLALCreateINT4VectorSequence(UINT4 length, UINT4 veclen)
#define PULSARCROSSCORR_ENULL
void LALCalculateEstimators(LALStatus *status, REAL8 *aplussq1, REAL8 *aplussq2, REAL8 *acrossq1, REAL8 *acrossq2, COMPLEX16Vector *yalpha, COMPLEX16Vector *gplus, COMPLEX16Vector *gcross, REAL8Vector *sigmaAlphasq)
#define PULSARCROSSCORR_EVAL
void LALCalculateAveUalpha(LALStatus *status, COMPLEX16 *out, REAL8 phiI, REAL8 phiJ, REAL8 freqI, REAL8 freqJ, REAL8 deltaF, CrossCorrBeamFn beamfnsI, CrossCorrBeamFn beamfnsJ, REAL8 sigmasq)
Calculate pair weights (U_alpha) for an average over Psi and cos(iota)
void LALCreateSFTPairsIndicesFrom2SFTvectors(LALStatus *status, INT4VectorSequence **out, SFTListElement *in, REAL8 lag, INT4 listLength, DetChoice detChoice, BOOLEAN autoCorrelate)
void LALCalculateSigmaAlphaSq(LALStatus *status, REAL8 *out, UINT4 bin1, UINT4 bin2, REAL8FrequencySeries *psd1, REAL8FrequencySeries *psd2)
void LALGetSignalFrequencyInSFT(LALStatus *status, REAL8 *out, LIGOTimeGPS *epoch, PulsarDopplerParams *dopp, REAL8Vector *vel_c)
Calculate the frequency of the SFT at a given epoch.
#define PULSARCROSSCORR_MSGENULL
void LALCorrelateSingleSFTPair(LALStatus *status, COMPLEX16 *out, COMPLEX8FrequencySeries *sft1, COMPLEX8FrequencySeries *sft2, REAL8FrequencySeries *psd1, REAL8FrequencySeries *psd2, UINT4 bin1, UINT4 bin2)
Correlate a single pair of SFT at a parameter space point.
void LALCalculateUalpha(LALStatus *status, COMPLEX16 *out, CrossCorrAmps amplitudes, REAL8 phiI, REAL8 phiJ, REAL8 freqI, REAL8 freqJ, REAL8 deltaF, CrossCorrBeamFn beamfnsI, CrossCorrBeamFn beamfnsJ, REAL8 sigmasq, REAL8 *psi, COMPLEX16 *gplus, COMPLEX16 *gcross)
Calculate pair weights (U_alpha) for the general case.
void LALGetSignalPhaseInSFT(LALStatus *status, REAL8 *out, LIGOTimeGPS *epoch, PulsarDopplerParams *dopp, REAL8Vector *r_c)
Get signal phase at a given epoch.
void LALCalculateCrossCorrPower(LALStatus *status, REAL8 *out, COMPLEX16Vector *yalpha, COMPLEX16Vector *ualpha)
#define PULSARCROSSCORR_MSGEVAL
void LALNormaliseCrossCorrPower(LALStatus *status, REAL8 *out, COMPLEX16Vector *ualpha, REAL8Vector *sigmaAlphasq)
#define PULSAR_MAX_SPINS
maximal number of spin-parameters (Freq + spindowns) we can handle
INT4Vector * XLALCreateINT4Vector(UINT4 length)
void XLALDestroyINT4Vector(INT4Vector *vector)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
REAL8 XLALGPSDiff(const LIGOTimeGPS *t1, const LIGOTimeGPS *t0)
Type containing the 'Doppler-parameters' affecting the time-evolution of the phase.
PulsarSpins fkdot
Intrinsic spins: [Freq, f1dot, f2dot, ...
REAL8 Delta
Sky position: DEC (latitude) in equatorial coords and radians.
LIGOTimeGPS refTime
Reference time of pulsar parameters (in SSB!)
REAL8 Alpha
Sky position: RA (longitude) in equatorial coords and radians.
struct tagSFTListElement * nextSFT