32#define THRESHOLDFRACSS 0.667
39#define SSMAX(x,y) ( (x) > (y) ? (x) : (y) )
40#define SSMIN(x,y) ( (x) < (y) ? (x) : (y) )
42#define BLOCKSIZE_REALLOC 50
69 REAL8 *pstackslideData;
73 REAL8 alphaStart, alphaEnd, dAlpha, thisAlpha;
74 REAL8 deltaStart, deltaEnd, dDelta, thisDelta;
75 REAL8 fdotStart, dfdot, thisFdot;
76 UINT4 ialpha, nalpha, idelta, ndelta, ifdot, nfdot;
80 INT4 fBinIni, fBinFin, nSearchBins, nStackBinsm1;
81 INT4 j,
k, nStacks, offset, offsetj;
82 INT4 extraBinsFstat, halfExtraBinsFstat;
86 REAL8 patchSizeX, patchSizeY;
107 if (
params->useToplist ) {
112 pixelFactor =
params->pixelFactor;
114 extraBinsFstat = (
INT4 )
params->extraBinsFstat;
115 halfExtraBinsFstat = extraBinsFstat / 2;
117 nSearchBins -= extraBinsFstat;
124 fBinIni = floor( vecF->
data[0].
f0 * tEffSTK + 0.5 );
128 fmid = ( (
REAL8 )( ( fBinIni + fBinFin ) / 2 ) ) *
deltaF;
130 weightsV =
params->weightsV;
131 threshold =
params->threshold;
140 refTimeGPS =
params->refTime;
146 stackslideSum.
f0 =
f0;
150 pstackslideData = stackslideSum.
data->
data;
158 patchSizeX =
params->patchSizeX;
159 patchSizeY =
params->patchSizeY;
161 if ( patchSizeX < 0 ) {
162 patchSizeX = 0.5 / ( fBinFin *
VEPI );
165 if ( patchSizeY < 0 ) {
166 patchSizeY = 0.5 / ( fBinFin *
VEPI );
169 LogPrintf(
LOG_DEBUG,
"StackSlide patchsize is %f rad x %f rad\n", patchSizeX, patchSizeY );
172 alphaStart =
alpha - patchSizeX / 2.0;
173 alphaEnd =
alpha + patchSizeX / 2.0;
174 deltaStart =
delta + patchSizeY / 2.0;
175 deltaEnd =
delta + patchSizeY / 2.0;
176 dDelta = 1.0 / (
VTOT * pixelFactor * fBinFin );
177 ndelta = floor( ( deltaEnd - deltaStart ) / dDelta + 0.5 );
186 for (
k = 0;
k < nStacks;
k++ ) {
189 timeDiffV->
data[
k] = tMidStack - refTime;
196 fdotStart = fdot - dfdot * (
REAL8 )( nfdot / 2 );
203 inputPoint.
refTime = refTimeGPS;
204 inputPoint.
asini = 0 ;
206 inputPoint.
fkdot[0] = fmid;
207 inputPoint.
fkdot[1] = fdot;
212 outputPoint.
refTime = refTimeGPS;
213 outputPoint.
asini = 0 ;
217 outputPointUnc.
refTime = refTimeGPS;
218 outputPointUnc.
asini = 0 ;
221 outputPointUnc.
fkdot[1] = dfdot;
222 outputPointUnc.
Delta = dDelta;
227 for ( idelta = 0; idelta < ndelta; idelta++ ) {
229 thisDelta = deltaStart + ( (
REAL8 )idelta ) * dDelta;
234 dAlpha = dDelta / cos( thisDelta );
235 nalpha = ceil( ( alphaEnd - alphaStart ) / dAlpha );
239 dAlpha = ( alphaEnd - alphaStart ) / ( (
REAL8 )nalpha );
244 outputPointUnc.
Alpha = dAlpha;
247 for ( ialpha = 0; ialpha < nalpha; ialpha++ ) {
248 thisAlpha = alphaStart + ( (
REAL8 )ialpha ) * dAlpha;
251 for ( ifdot = 0; ifdot < nfdot; ifdot++ ) {
252 thisFdot = fdotStart + ( (
REAL8 )ifdot ) * dfdot;
255 outputPoint.
fkdot[0] = fmid;
256 outputPoint.
fkdot[1] = thisFdot;
257 outputPoint.
Alpha = thisAlpha;
258 outputPoint.
Delta = thisDelta;
261 for (
k = 0;
k < nStacks;
k++ ) {
268 offset = floor( ( outputPoint.
fkdot[0] - fmid ) * tEffSTK + 0.5 );
270#ifdef PRINT_STACKSLIDE_BINOFFSETS
276 if ( weightsV == NULL ) {
278 for (
j = 0;
j < nSearchBins;
j++ ) {
280 offsetj =
j + halfExtraBinsFstat + offset;
285 if ( offsetj > nStackBinsm1 ) {
290 pstackslideData[
j] = pFVecData[offsetj];
292 pstackslideData[
j] += pFVecData[offsetj];
297 thisWeight = weightsV->
data[
k];
298 for (
j = 0;
j < nSearchBins;
j++ ) {
300 offsetj =
j + halfExtraBinsFstat + offset;
305 if ( offsetj > nStackBinsm1 ) {
310 pstackslideData[
j] = thisWeight * pFVecData[offsetj];
312 pstackslideData[
j] += thisWeight * pFVecData[offsetj];
321 if (
params->useToplist && threshold <= 0.0 ) {
340 if (
params->useToplist && threshold <= 0.0 ) {
341 for ( uk = 0; uk < stackslideToplist->
elems; uk++ ) {
344 out->nCandidates = stackslideToplist->
elems;
346 }
else if (
params->useToplist ) {
349 for ( uk = 0; uk < (
UINT4 )
out->nCandidates; uk++ ) {
353 for ( uk = 0; uk < stackslideToplist->
elems; uk++ ) {
356 out->nCandidates = stackslideToplist->
elems;
380 INT8 fBinIni, fBinFin, fBin;
384 REAL8 patchSizeX, patchSizeY;
409 if (
out->length == 0 ) {
412 if (
out->list == NULL ) {
415 if ( vecF == NULL ) {
418 if ( vecF->
length == 0 ) {
421 if ( vecF->
data == NULL ) {
444 refTimeGPS =
params->refTime;
453 patchSizeX =
params->patchSizeX;
454 patchSizeY =
params->patchSizeY;
459 for (
k = 0;
k < nStacks;
k++ ) {
462 timeDiffV->
data[
k] = tMidStack - refTime;
470 if ( freqInd.
data == NULL ) {
522 REAL8 maxTimeDiff, startTimeDiff, endTimeDiff;
524 startTimeDiff = fabs( timeDiffV->
data[0] );
525 endTimeDiff = fabs( timeDiffV->
data[timeDiffV->
length - 1] );
526 maxTimeDiff =
SSMAX( startTimeDiff, endTimeDiff );
531 nfSize = 2 * floor( ( nfdot - 1 ) * (
REAL4 )( dfdot * maxTimeDiff /
deltaF ) + 0.5f ) + 1;
536 parRes.
f0Bin = fBinIni;
538 fBinIni +=
params->extraBinsFstat;
539 fBinFin -=
params->extraBinsFstat;
543 fBinIni *
deltaF, fBinFin *
deltaF, fBinFin - fBinIni + 1 );
548 out->nCandidates = 0;
551 if (
params->useToplist ) {
555 INT4 numHmaps = ( fBinFin - fBinIni + 1 ) * nfSize;
556 if (
out->length != numHmaps ) {
557 out->length = numHmaps;
559 if (
out->list == NULL ) {
570 while ( fBin <= fBinFin ) {
571 INT8 fBinSearch, fBinSearchMax;
576 xSide = parSize.
xSide;
577 ySide = parSize.
ySide;
585 if ( patch.
xCoor == NULL ) {
590 if ( patch.
yCoor == NULL ) {
608 if ( ht.
map == NULL ) {
616 fBinSearchMax = fBin + parSize.
nFreqValid - 1;
619 while ( ( fBinSearch <= fBinFin ) && ( fBinSearch < fBinSearchMax ) ) {
625 nfdotBy2 = nfdot / 2;
626 ht.
f0Bin = fBinSearch;
630 for (
n = -nfdotBy2;
n <= nfdotBy2 ;
n++ ) {
634 for (
j = 0;
j < (
UINT4 )nStacks;
j++ ) {
644 if (
params->useToplist ) {
667 if (
params->useToplist ) {
668 for (
k = 0;
k < houghToplist->
elems;
k++ ) {
671 out->nCandidates = houghToplist->
elems;
714 REAL8 kFact, deltaTPowk;
728 cosAlpha = cos(
alpha );
729 cosDelta = cos(
delta );
730 sinDelta = sin(
delta );
731 ndx = cosDelta * cosAlpha;
732 ndy = cosDelta * sinDelta;
738 cosAlpha = cos(
alpha );
739 cosDelta = cos(
delta );
740 sinDelta = sin(
delta );
741 nx = cosDelta * cosAlpha;
742 ny = cosDelta * sinDelta;
750 for (
k = 1;
k <= numSpindown;
k++ ) {
751 inputfkdot[
k] = inputPoint->
fkdot[
k];
752 deltafkdot[
k] = outputPoint->
fkdot[
k] - inputPoint->
fkdot[
k];
764 for (
k = 1;
k <= numSpindown;
k++ ) {
767 F0 += deltafkdot[
k] * deltaTPowk / kFact;
774 for (
k = 1;
k <= numSpindown;
k++ ) {
777 F0zeta += inputfkdot[
k] * deltaTPowk / kFact;
782 outputPoint->
fkdot[0] =
F0 + F0zeta * (
vx * (
nx - ndx ) +
vy * (
ny - ndy ) +
vz * (
nz - ndz ) );
797 INT4 j, jminus1, jplus1, nSearchBins, nSearchBinsm1, numCandidates;
800 REAL8 thisSig, thisSigMinus1, thisSigPlus1;
801 REAL8 *pstackslideData;
813 pstackslideData = stackslideSum->
data->
data;
816 f0 = stackslideSum->
f0;
819 thisCandidate.
fdot = outputPoint->
fkdot[1];
820 thisCandidate.
dFdot = outputPointUnc->
fkdot[1];
830 numCandidates =
out->nCandidates;
832 nSearchBinsm1 = nSearchBins - 1;
835 for (
j = 0;
j < nSearchBins;
j++ ) {
839 if ( numCandidates >=
out->length ) {
845 thisSig = pstackslideData[
j];
848 if ( thisSig > threshold ) {
853 if ( jplus1 > nSearchBinsm1 ) {
854 jplus1 = nSearchBinsm1;
856 thisSigPlus1 = pstackslideData[jplus1];
857 isLocalMax = ( thisSig > thisSigPlus1 );
858#ifdef INCLUDE_EXTRA_STACKSLIDE_THREHOLDCHECK
859 isLocalMax = ( isLocalMax && ( thisSig > 2.0 *
THRESHOLDFRACSS * thisSigPlus1 ) );
861 }
else if ( jplus1 > nSearchBinsm1 ) {
865 thisSigMinus1 = pstackslideData[jminus1];
866 isLocalMax = ( thisSig > thisSigMinus1 );
867#ifdef INCLUDE_EXTRA_STACKSLIDE_THREHOLDCHECK
868 isLocalMax = ( isLocalMax && ( thisSig > 2.0 *
THRESHOLDFRACSS * thisSigMinus1 ) );
871 thisSigMinus1 = pstackslideData[jminus1];
872 thisSigPlus1 = pstackslideData[jplus1];
873 isLocalMax = ( thisSig > thisSigMinus1 ) && ( thisSig > thisSigPlus1 );
874#ifdef INCLUDE_EXTRA_STACKSLIDE_THREHOLDCHECK
875 isLocalMax = ( isLocalMax && ( thisSig >
THRESHOLDFRACSS * ( thisSigMinus1 + thisSigPlus1 ) ) );
878 if ( ( numCandidates < out->length ) && isLocalMax ) {
881 out->list[numCandidates] = thisCandidate;
883 out->nCandidates = numCandidates;
903 REAL8 *pstackslideData;
912 pstackslideData = stackslideSum->
data->
data;
914 f0 = stackslideSum->
f0;
917 thisCandidate.
fdot = outputPoint->
fkdot[1];
918 thisCandidate.
dFdot = outputPointUnc->
fkdot[1];
927 for (
j = 0;
j < nSearchBins;
j++ ) {
int create_toplist(toplist_t **list, size_t length, size_t size, int(*smaller)(const void *, const void *))
void free_toplist(toplist_t **list)
void * toplist_elem(toplist_t *list, size_t ind)
int insert_into_toplist(toplist_t *list, void *element)
#define HIERARCHICALSEARCH_MSGENULL
#define HIERARCHICALSEARCH_ENULL
#define HIERARCHICALSEARCH_EVAL
#define HIERARCHICALSEARCH_MSGEVAL
void GetHoughCandidates_toplist(LALStatus *status, toplist_t *list, HOUGHMapTotal *ht, HOUGHPatchGrid *patch, HOUGHDemodPar *parDem)
Get Hough candidates as a toplist.
void GetHoughCandidates_threshold(LALStatus *status, SemiCohCandidateList *out, HOUGHMapTotal *ht, HOUGHPatchGrid *patch, HOUGHDemodPar *parDem, REAL8 threshold)
Get Hough candidates as a toplist using a fixed threshold.
static double double delta
#define ABORT(statusptr, code, mesg)
#define TRY(func, statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
void GetStackSlideCandidates_toplist(LALStatus *status, toplist_t *list, REAL8FrequencySeries *stackslideSum, PulsarDopplerParams *outputPoint, PulsarDopplerParams *outputPointUnc)
#define BLOCKSIZE_REALLOC
static int smallerStackSlide(const void *a, const void *b)
void GetStackSlideCandidates_threshold(LALStatus *status, SemiCohCandidateList *out, REAL8FrequencySeries *stackslideSum, PulsarDopplerParams *outputPoint, PulsarDopplerParams *outputPointUnc, REAL8 threshold)
void StackSlideVecF(LALStatus *status, SemiCohCandidateList *out, REAL4FrequencySeriesVector *vecF, SemiCoherentParams *params)
Function StackSlides a vector of Fstat frequency series or any REAL8FrequencySeriesVector.
void StackSlideVecF_HoughMode(LALStatus *status, SemiCohCandidateList *out, REAL4FrequencySeriesVector *vecF, SemiCoherentParams *params)
Function StackSlides a vector of Fstat frequency series or any REAL8FrequencySeriesVector.
void FindFreqFromMasterEquation(LALStatus *status, PulsarDopplerParams *outputPoint, PulsarDopplerParams *inputPoint, REAL8 *vel, REAL8 deltaT, UINT2 numSpindown)
Header file for StackSlideFstat.c.
#define STACKSLIDEFSTAT_ENULL
#define STACKSLIDEFSTAT_EVAL
#define STACKSLIDEFSTAT_MSGENULL
#define STACKSLIDEFSTAT_MSGEVAL
REAL8 HoughTT
Total Hough Map pixel type.
void LALHOUGHInitializeHT(LALStatus *status, HOUGHMapTotal *ht, HOUGHPatchGrid *patch)
This function initializes the total Hough map HOUGHMapTotal *ht to zero and checks consistency betwee...
#define VTOT
Total detector velocity/c TO BE CHANGED DEPENDING ON DETECTOR.
#define PIXERR
Maximum `‘error’' (as a fraction of the width of the thinnest annulus) which allows to consider two b...
#define LINERR
Maximum `‘error’' (as a fraction of the width of the thinnest annulus) which allows to represent a ci...
void LALHOUGHFillPatchGrid(LALStatus *status, HOUGHPatchGrid *out, HOUGHSizePar *par)
#define VEPI
Earth v_epicycle/c TO BE CHANGED DEPENDING ON DETECTOR.
void LALHOUGHComputeSizePar(LALStatus *status, HOUGHSizePar *out, HOUGHResolutionPar *in)
void LogPrintf(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
REAL8 PulsarSpins[PULSAR_MAX_SPINS]
Typedef for fixed-size array holding GW frequency and derivatives fk = d^k Freq/dt^k|(tau_ref)
void LALDCreateVector(LALStatus *, REAL8Vector **, UINT4)
void LALDDestroyVector(LALStatus *, REAL8Vector **)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
Demodulation parameters needed for the Hough transform; all coordinates are assumed to be with respec...
REAL8 deltaF
Frequency resolution: df=1/TCOH
REAL8Vector spin
Spin down information.
REAL8UnitPolarCoor skyPatch
(alpha, delta): position of the center of the patch
This structure stores the Hough map.
UINT2 ySide
number of physical pixels in the y direction
UINT2 xSide
number of physical pixels in the x direction
HoughTT * map
the pixel counts; the number of elements to allocate is ySide*xSide
REAL8Vector dFdot
resolution in spindown parameters
REAL8Vector spinRes
Refined spin parameters used in the Hough transform.
REAL8UnitPolarCoor skyPatch
Coordinates of the versor (alpha, delta) pointing to the center of the sky patch.
INT8 f0Bin
frequency bin for which it has been constructed
UINT4 mObsCoh
ratio of observation time and coherent timescale
REAL8 patchSizeX
x size of patch
REAL8 deltaF
frequency resolution
REAL8 patchSizeY
y size of patch
REAL8Vector spinDem
Spin parameters used in the demodulation stage.
This structure stores patch-frequency grid information.
UINT2 ySide
Real number of pixels in the y-direction (in the projected plane).
REAL8 * xCoor
Coordinates of the pixel centers.
UINT2 xSide
Real number of pixels in the x direction (in the projected plane); it should be less than or equal to...
REAL8 * yCoor
Coordinates of the pixel centers.
parameters needed for gridding the patch
REAL8 deltaF
Frequency resolution: df=1/TCOH
REAL8 pixErr
for validity of LUT as PIXERR
INT8 f0Bin
Frequency bin at which construct the grid.
REAL8 patchSkySizeY
Patch size in radians along y-axis.
REAL8 patchSkySizeX
Patch size in radians along x-axis.
REAL8 pixelFactor
number of pixel that fit in the thinnest annulus
REAL8 vTotC
estimate value of v-total/C as VTOT
REAL8 linErr
as LINERR circle ->line
required for constructing patch
UINT2 ySide
number of pixels in the y direction
INT8 nFreqValid
number of frequencies where the LUT is valid
UINT2 xSide
number of pixels in the x direction (projected plane)
A vector of 'timestamps' of type LIGOTimeGPS.
LIGOTimeGPS * data
array of timestamps
Type containing the 'Doppler-parameters' affecting the time-evolution of the phase.
PulsarSpins fkdot
Intrinsic spins: [Freq, f1dot, f2dot, ... ] where fkdot = d^kFreq/dt^k.
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.
REAL8 asini
Binary: projected, normalized orbital semi-major axis (s).
A vector of REAL4FrequencySeries.
REAL4FrequencySeries * data
Pointer to the data array.
UINT4 length
Number of elements in array.
REAL8 delta
In the interval [ ].
one hough or stackslide candidate
REAL8 varianceSig
variance of significance values in Hough map
REAL8 deltaBest
delta for best candidate in hough map
REAL8 meanSig
mean of significance values in hough map
REAL8 alpha
right ascension
REAL8 dFreq
frequency error
REAL8 alphaBest
alpha for best candidate in hough map
REAL8 significance
significance
structure for storing candidates produced by Hough search
parameters for the semicoherent stage
This structure stores the frequency indexes of the partial-Hough map derivatives at different time st...
UINT8 * data
the frequency indexes
REAL8 deltaF
frequency resolution
UINT4 length
number of elements