89#include <gsl/gsl_permutation.h>
91#include <lal/LogPrintf.h>
92#include <lal/DopplerScan.h>
93#include <lal/LALPulsarVCSInfo.h>
107#define EARTHEPHEMERIS "/home/badkri/lscsoft/share/lal/earth05-09.dat"
108#define SUNEPHEMERIS "/home/badkri/lscsoft/share/lal/sun05-09.dat"
110#define HOUGHMAXFILENAMELENGTH 512
112#define DIROUT "./outMulti"
113#define BASENAMEOUT "HM"
117#define SKYFILE "./skypatchfile"
122#define BLOCKSRNGMED 101
124#define SKYREGION "allsky"
131#define SPINDOWNJUMP 1
137typedef struct tagHoughParamsTest {
141 REAL8 *sumWeightSquare;
145typedef struct tagUCHARPeakGramVector {
158void ComputeandPrintChi2(
LALStatus *
status,
toplist_t *tl,
REAL8Vector *timeDiffV,
REAL8Cart3CoorVector *velV,
INT4 skyCounter,
INT4 nSkyPatches,
INT4 p,
REAL8 alphaPeak,
MultiDetectorStateSeries *mdetStates,
REAL8Vector *weightsNoise,
UCHARPeakGramVector *upgV );
238int main(
int argc,
char *argv[] )
262 REAL8Vector *weightsV = NULL, *weightsNoise = NULL;
287 REAL8 *skyAlpha = NULL, *skyDelta = NULL, *skySizeAlpha = NULL, *skySizeDelta = NULL;
288 INT4 nSkyPatches, skyCounter = 0;
297 FILE *fpSigma = NULL;
303 INT4 iHmap, nSpin1Max ;
304 UINT4 mObsCoh, mObsCohBest;
305 INT8 f0Bin, fLastBin, fBin;
307 REAL8 patchSizeX, patchSizeY;
308 REAL8 alphaPeak, minSignificance, maxSignificance;
311 UINT2 maxNBins, maxNBorders;
321 BOOLEAN uvar_weighAM, uvar_weighNoise, uvar_printLog;
323 INT4 uvar_keepBestSFTs = 1;
326 REAL8 uvar_pixelFactor;
329 CHAR *uvar_earthEphemeris = NULL;
330 CHAR *uvar_sunEphemeris = NULL;
331 CHAR *uvar_sftData = NULL;
333 CHAR *uvar_fbasenameOut = NULL;
335 CHAR *uvar_timeStampsFile = NULL;
341 INT4 uvar_spindownJump;
343 INT4 uvar_nfLUTvalidity = 0;
344 INT4 uvar_numSkyPartitions = 0;
345 INT4 uvar_partitionIndex = 0;
350 REAL8 uvar_deltaF1dot;
358 uvar_weighNoise =
TRUE;
359 uvar_printLog =
FALSE;
361 uvar_nfSizeCylinder =
NFSIZE;
364 uvar_freqBand =
FBAND;
366 uvar_maxBinsClean = 100;
367 uvar_binsHisto = 1000;
414 " - '<SFT file>;<SFT file>;...', where <SFT file> may contain wildcards\n - 'list:<file containing list of SFT files>'" ) ==
XLAL_SUCCESS,
XLAL_EFUNC );
454 if ( uvar_freqBand < 0 ) {
459 if ( uvar_peakThreshold < 0 ) {
465 alphaPeak = exp( -uvar_peakThreshold );
468 if ( uvar_binsHisto < 1 ) {
473 if ( uvar_nfSizeCylinder < uvar_nSpinUp + 1 ) {
478 if ( uvar_keepBestSFTs < 1 ) {
484 if ( uvar_printLog ) {
495 skyAlpha = skyInfo.
alpha;
496 skyDelta = skyInfo.
delta;
534 constraints.
timestamps = &inputTimeStampsVector;
539 if ( ( catalog == NULL ) || ( catalog->
length == 0 ) ) {
554 f0Bin = floor(
uvar_f0 * timeBase + 0.5 );
555 numSearchBins = uvar_freqBand * timeBase;
556 fLastBin = f0Bin + numSearchBins;
567 numifo = inputSFTs->
length;
574 for (
k = 0;
k < (
INT4 )numifo;
k++ ) {
581 if (
XLALUserVarWasSet( &uvar_keepBestSFTs ) && ( uvar_weighNoise || uvar_weighAM ) ) {
582 mObsCohBest = uvar_keepBestSFTs;
585 if ( mObsCohBest > mObsCoh ) {
586 mObsCohBest = mObsCoh;
589 mObsCohBest = mObsCoh;
599 tObs =
XLALGPSDiff( &lastTimeStamp, &refTimeGPS ) + timeBase;
601 tObs =
XLALGPSDiff( &lastTimeStamp, &firstTimeStamp ) + timeBase;
615 if ( ( fpRand = fopen(
"/dev/urandom",
"r" ) ) == NULL ) {
620 if ( ( ranCount = fread( &
seed,
sizeof(
seed ), 1, fpRand ) ) != 1 ) {
674 if ( uvar_weighNoise ) {
690 if ( uvar_weighNoise ) {
699 for (
j = 0;
j < mObsCoh;
j++ ) {
703 for (
j = 0;
j < mObsCoh;
j++ ) {
736 strcat( fileSigma,
"/" );
737 strcat( fileSigma, uvar_fbasenameOut );
738 strcat( fileSigma,
"sigma" );
740 if ( ( fpSigma = fopen( fileSigma,
"w" ) ) == NULL ) {
748 minSignificance = -sqrt( mObsCohBest * alphaPeak / ( 1 - alphaPeak ) );
749 maxSignificance = sqrt( mObsCohBest * ( 1 - alphaPeak ) / alphaPeak );
755 LogPrintf(
LOG_NORMAL,
"Starting loop over skypatches and chi-square follow-up of top candidates per patch: " );
761 for ( skyCounter = 0; skyCounter < nSkyPatches; skyCounter++ ) {
763 REAL8 sumWeightSquare;
770 alpha = skyAlpha[skyCounter];
771 delta = skyDelta[skyCounter];
772 patchSizeX = skySizeDelta[skyCounter];
773 patchSizeY = skySizeAlpha[skyCounter];
776 if ( uvar_weighNoise ) {
777 memcpy( weightsV->
data, weightsNoise->data, mObsCoh *
sizeof(
REAL8 ) );
781 if ( uvar_weighAM ) {
786 temp.length = mObsCoh;
787 temp.weightsV = weightsV;
788 temp.timeDiffV = timeDiffV;
792 if ( uvar_weighAM || uvar_weighNoise ) {
802 sumWeightSquare = 0.0;
803 for (
k = 0;
k < mObsCohBest;
k++ ) {
808 meanN = mObsCohBest * alphaPeak;
809 sigmaN = sqrt( sumWeightSquare * alphaPeak * ( 1.0 - alphaPeak ) );
813 fprintf( fpSigma,
"%f\n", sigmaN );
868 nSpin1Max = uvar_nfSizeCylinder - 1 - uvar_nSpinUp;
873 f1jump = uvar_deltaF1dot * uvar_spindownJump;
875 f1jump = 1. / tObs * uvar_spindownJump;
884 while ( fBin <= fLastBin ) {
885 INT8 fBinSearch, fBinSearchMax;
892 xSide = parSize.
xSide;
893 ySide = parSize.
ySide;
896 if ( uvar_nfLUTvalidity ) {
917 for (
j = 0;
j < mObsCohBest; ++
j ) {
929 phmdVS.
fBinMin = fBin - uvar_nfSizeCylinder + 1 + uvar_nSpinUp;
933 if ( uvar_weighAM || uvar_weighNoise ) {
946 fBinSearchMax = fBin + parSize.
nFreqValid - 1 - uvar_nSpinUp;
952 while ( ( fBinSearch <= fLastBin ) && ( fBinSearch < fBinSearchMax ) ) {
959 ht.
f0Bin = fBinSearch;
963 for (
n = floor( uvar_nSpinUp / uvar_spindownJump );
n >= - floor( nSpin1Max / uvar_spindownJump ); --
n ) {
968 f1dis = +
n * f1jump;
972 for (
j = 0 ;
j < mObsCohBest; ++
j ) {
976 if ( uvar_weighAM || uvar_weighNoise ) {
993 minSignificance, maxSignificance ), &
status );
995 for (
j = 0;
j < histTotal->
length;
j++ ) {
1023 if ( uvar_weighAM || uvar_weighNoise ) {
1046 LAL_CALL(
ComputeandPrintChi2( &
status, toplist, timeDiffV, &velV, skyCounter, nSkyPatches, uvar_chiSqBins, alphaPeak, mdetStates, weightsNoise, &upgV ), &
status );
1056 if (
PrintHistogram( histTotal, filehisto, minSignificance, maxSignificance ) ) {
1075 freqInd.
data = NULL;
1100 LAL_CALL(
ComputeandPrintChi2( &
status, toplist, timeDiffV, &velV, -1, 0, uvar_chiSqBins, alphaPeak, mdetStates, weightsNoise, &upgV ), &
status );
1105 FILE *fpToplist = NULL;
1108 fpToplist = fopen(
"hough_top.dat",
"w" );
1116 if (
fprintf( fpToplist,
"%%DONE\n" ) < 0 ) {
1120 fclose( fpToplist );
1128 for (
j = 0;
j < mObsCoh; ++
j ) {
1138 for (
j = 0;
j < mObsCoh; ++
j ) {
1164 if ( nStarEventVec.
event ) {
1188 return status.statusCode;
1206 strcpy( filestats, base );
1208 strcat( filestats,
"/skypatch_" );
1209 sprintf( tempstr,
"%d", ind );
1210 strcat( filestats, tempstr );
1211 strcat( filestats,
"/" );
1216 mkdir_result = mkdir( filestats, S_IRWXU | S_IRWXG | S_IRWXO );
1218 if ( ( mkdir_result == -1 ) && ( errno != EEXIST ) ) {
1219 fprintf( stderr,
"unable to create skypatch directory %d\n", ind );
1240 binsHisto = hist->
length;
1241 dSig = ( maxSignificance - minSignificance ) / binsHisto;
1243 if ( (
fp = fopen(
filename,
"w" ) ) == NULL ) {
1248 for (
i = 0;
i < binsHisto;
i++ ) {
1272 sprintf( filenumber,
".%06d", iHmap );
1275 if ( (
fp = fopen(
filename,
"w" ) ) == NULL ) {
1283 for (
k = ySide - 1;
k >= 0; --
k ) {
1284 for (
i = 0;
i < xSide; ++
i ) {
1311 sprintf( filenumber,
"%06d.m", iHmap );
1334 for (
k = ySide - 1;
k >= 0; --
k ) {
1335 for (
i = 0;
i < xSide; ++
i ) {
1357 CHAR *fnameLog = NULL;
1359 CHAR *logstr = NULL;
1367 strcpy( fnameLog, dir );
1368 strcat( fnameLog,
"/logfiles/" );
1375 mkdir_result = mkdir( fnameLog, S_IRWXU | S_IRWXG | S_IRWXO );
1376 if ( ( mkdir_result == -1 ) && ( errno != EEXIST ) ) {
1377 fprintf( stderr,
"unable to create logfiles directory %s\n", fnameLog );
1384 strcat( fnameLog, basename );
1385 strcat( fnameLog,
".log" );
1387 if ( ( fpLog = fopen( fnameLog,
"w" ) ) == NULL ) {
1388 fprintf( stderr,
"Unable to open file %s for writing\n", fnameLog );
1396 fprintf( fpLog,
"## LOG FILE FOR Hough Driver\n\n" );
1397 fprintf( fpLog,
"# User Input:\n" );
1398 fprintf( fpLog,
"#-------------------------------------------\n" );
1399 fprintf( fpLog,
"%s", logstr );
1403 fprintf( fpLog,
"\n\n# Contents of skypatch file:\n" );
1406 CHAR command[1024] =
"";
1407 sprintf( command,
"cat %s >> %s", skyfile, fnameLog );
1408 if ( system( command ) ) {
1409 fprintf( stderr,
"\nsystem('%s') returned non-zero status!\n\n", command );
1417 for (
k = 0;
k < linefiles->
length;
k++ ) {
1419 if ( ( fpLog = fopen( fnameLog,
"a" ) ) != NULL ) {
1420 CHAR command[1024] =
"";
1421 fprintf( fpLog,
"\n\n# Contents of linefile %s :\n", linefiles->
data[
k] );
1422 fprintf( fpLog,
"# -----------------------------------------\n" );
1424 sprintf( command,
"cat %s >> %s", linefiles->
data[
k], fnameLog );
1425 if ( system( command ) ) {
1426 fprintf( stderr,
"\nsystem('%s') returned non-zero status!\n\n", command );
1433 if ( ( fpLog = fopen( fnameLog,
"a" ) ) != NULL ) {
1434 CHAR command[1024] =
"";
1435 fprintf( fpLog,
"\n\n# CVS-versions of executable:\n" );
1436 fprintf( fpLog,
"# -----------------------------------------\n" );
1439 sprintf( command,
"ident %s | sort -u >> %s", executable, fnameLog );
1443 if ( system( command ) ) {
1444 fprintf( stderr,
"\nsystem('%s') returned non-zero status!\n\n", command );
1463 INT4 numTimeStamps,
r;
1475 if ( (
fp = fopen(
filename,
"r" ) ) == NULL ) {
1483 r =
fscanf(
fp,
"%lf%lf\n", &temp1, &temp2 );
1488 }
while (
r != EOF );
1491 ts->length = numTimeStamps;
1493 if (
ts->data == NULL ) {
1498 for (
j = 0;
j <
ts->length;
j++ ) {
1499 r =
fscanf(
fp,
"%lf%lf\n", &temp1, &temp2 );
1500 ts->data[
j].gpsSeconds = (
INT4 )temp1;
1501 ts->data[
j].gpsNanoSeconds = (
INT4 )temp2;
1522 REAL8 minSignificance,
1523 REAL8 maxSignificance )
1526 INT4 i,
j, binsHisto, xSide, ySide, binIndex;
1544 binsHisto =
out->length;
1549 for (
i = 0;
i < binsHisto;
i++ ) {
1554 for (
i = 0;
i < ySide;
i++ ) {
1555 for (
j = 0;
j < xSide;
j++ ) {
1558 temp = ( in->
map[
i * xSide +
j] - mean ) / sigma;
1564 binIndex = (
INT4 ) binsHisto * (
temp - minSignificance ) / ( maxSignificance - minSignificance );
1571 out->data[binIndex] += 1;
1589 UINT4 numifo, numsft, iIFO, iSFT,
j;
1610 for (
j = 0, iIFO = 0; iIFO < numifo; iIFO++ ) {
1617 for ( iSFT = 0; iSFT < numsft; iSFT++,
j++ ) {
1644 UINT4 numifo, numsft, iIFO, iSFT,
j;
1659 for (
j = 0, iIFO = 0; iIFO < numifo; iIFO++ ) {
1666 for ( iSFT = 0; iSFT < numsft; iSFT++,
j++ ) {
1693 UINT4 iIFO, iSFT, numsft, numifo,
j, binsSFT;
1706 for (
j = 0, iIFO = 0; iIFO < numifo; iIFO++ ) {
1710 for ( iSFT = 0; iSFT < numsft; iSFT++,
j++ ) {
1719 out->pg[
j].length = nPeaks;
1720 out->pg[
j].peak = NULL;
1750 INT4 numSkyPartitions,
1751 INT4 partitionIndex )
1756 UINT4 nSkyPatches, skyCounter;
1768 scanInit.dAlpha = dAlpha;
1769 scanInit.dDelta = dDelta;
1779 scanInit.skyRegionString = (
CHAR * )
LALCalloc( 1, strlen( skyRegion ) + 1 );
1780 strcpy( scanInit.skyRegionString, skyRegion );
1783 scanInit.numSkyPartitions = numSkyPartitions;
1784 scanInit.partitionIndex = partitionIndex;
1789 nSkyPatches =
out->numSkyPatches = thisScan.numSkyGridPoints;
1802 out->alpha[skyCounter] = dopplerpos.
Alpha;
1803 out->delta[skyCounter] = dopplerpos.
Delta;
1804 out->alphaSize[skyCounter] = dAlpha;
1805 out->deltaSize[skyCounter] = dDelta;
1821 if ( scanInit.skyRegionString ) {
1822 LALFree( scanInit.skyRegionString );
1831 REAL8 temp1, temp2, temp3, temp4;
1835 if ( ( fpsky = fopen( skyFileName,
"r" ) ) == NULL ) {
1841 r =
fscanf( fpsky,
"%lf%lf%lf%lf\n", &temp1, &temp2, &temp3, &temp4 );
1846 }
while (
r != EOF );
1849 out->numSkyPatches = nSkyPatches;
1855 for ( skyCounter = 0; skyCounter < nSkyPatches; skyCounter++ ) {
1856 r =
fscanf( fpsky,
"%lf%lf%lf%lf\n",
out->alpha + skyCounter,
out->delta + skyCounter,
1857 out->alphaSize + skyCounter,
out->deltaSize + skyCounter );
1881 UINT4 iIFO, iSFT,
k, numsft, numifo;
1894 numifo = mdetStates->
length;
1898 for (
k = 0, iIFO = 0; iIFO < numifo; iIFO++ ) {
1902 for ( iSFT = 0; iSFT < numsft; iSFT++,
k++ ) {
1905 b = multiAMcoef->
data[iIFO]->
b->
data[iSFT];
1906 out->data[
k] *= (
a *
a + b * b );
1960 out->length = mObsCohBest;
1963 if (
out->weightsV == NULL ) {
1965 out->weightsV->length = mObsCohBest;
1969 if (
out->timeDiffV == NULL ) {
1971 out->timeDiffV->length = mObsCohBest;
1975 if (
out->velV == NULL ) {
1977 out->velV->length = mObsCohBest;
1981 if (
out->pgV == NULL ) {
1983 out->pgV->length = mObsCohBest;
1987 ind =
LALCalloc( 1, mObsCohBest *
sizeof(
size_t ) );
1988 gsl_sort_largest_index( ind, mObsCohBest, in->
weightsV->
data, 1, mObsCoh );
1990 for (
k = 0;
k < mObsCohBest;
k++ ) {
2046 out->length = mObsCoh;
2048 if (
out->weightsV == NULL ) {
2050 out->weightsV->length = mObsCoh;
2054 if (
out->timeDiffV == NULL ) {
2056 out->timeDiffV->length = mObsCoh;
2060 if (
out->velV == NULL ) {
2062 out->velV->length = mObsCoh;
2066 if (
out->pgV == NULL ) {
2068 out->pgV->length = mObsCoh;
2098 if ( lutV == NULL ) {
2102 if ( lutV->
lut != NULL ) {
2106 if ( length <= 0 ) {
2135 if ( lutV == NULL ) {
2139 if ( lutV->
lut == NULL ) {
2143 if ( maxNBins <= 0 ) {
2147 if ( maxNBorders <= 0 ) {
2163 for (
i = 0;
i < maxNBorders;
i++ ) {
2222 if ( phmdVS == NULL ) {
2226 if ( phmdVS->
phmd != NULL ) {
2230 if ( length <= 0 ) {
2234 if ( nfSize <= 0 ) {
2266 if ( phmdVS == NULL ) {
2270 if ( phmdVS->
phmd == NULL ) {
2274 if ( maxNBins <= 0 ) {
2278 if ( maxNBorders <= 0 ) {
2377 if ( freqInd == NULL ) {
2381 if ( length <= 0 ) {
2390 freqInd->
length = length;
2391 freqInd->
data = NULL;
2433 for (
i = 0;
i < ySide;
i++ ) {
2434 for (
j = 0;
j < xSide;
j++ ) {
2476 strcat( filestats, basename );
2477 strcpy( filehisto, filestats );
2478 strcpy( fileMaps, filestats );
2482 strcat( filestats,
"stats" );
2483 if ( ( fp1 = fopen( filestats,
"w" ) ) == NULL ) {
2484 fprintf( stderr,
"Unable to find file %s for writing\n", filestats );
2487 setvbuf( fp1, (
char * )NULL, _IOLBF, 0 );
2505 FILE *fp1 = *fp1_ptr;
2516 fprintf( fp1,
"%d %f %f %f %f %f %f %f %g\n",
2517 iHmap, sourceLocation->
alpha, sourceLocation->
delta,
2539 REAL8 f0new, vcProdn, timeDiffN;
2540 REAL8 sourceDelta, sourceAlpha, cosDelta;
2541 INT4 j,
i, nspin, factorialN;
2558 sourceDelta = pulsarTemplate->
latitude;
2559 sourceAlpha = pulsarTemplate->
longitude;
2560 cosDelta = cos( sourceDelta );
2562 sourceLocation.
x = cosDelta * cos( sourceAlpha );
2563 sourceLocation.
y = cosDelta * sin( sourceAlpha );
2564 sourceLocation.
z = sin( sourceDelta );
2569 for (
j = 0;
j < mObsCoh; ++
j ) {
2570 vcProdn = velV->
data[
j].
x * sourceLocation.
x
2571 + velV->
data[
j].
y * sourceLocation.
y
2572 + velV->
data[
j].
z * sourceLocation.
z;
2573 f0new = pulsarTemplate->
f0;
2575 timeDiffN = timeDiffV->
data[
j];
2577 for (
i = 0;
i < nspin; ++
i ) {
2578 factorialN *= (
i + 1 );
2579 f0new += pulsarTemplate->
spindown.
data[
i] * timeDiffN / factorialN;
2580 timeDiffN *= timeDiffN;
2582 foft->
data[
j] = f0new * ( 1.0 + vcProdn );
2606 REAL8 sumWeightpMax;
2609 REAL8 partialsumWeightp, partialsumWeightSquarep;
2626 mObsCoh = weightsV->
length;
2629 sumWeightpMax = (
REAL8 )( mObsCoh ) /
p;
2630 weights_ptr = weightsV->
data;
2633 for (
j = 0;
j <
p;
j++ ) {
2635 partialsumWeightSquarep = 0;
2636 partialsumWeightp = 0;
2638 for ( numberSFT = 0; ( partialsumWeightp < sumWeightpMax ) && ( iSFT < mObsCoh ); numberSFT++, iSFT++ ) {
2640 partialsumWeightp += *weights_ptr;
2641 partialsumWeightSquarep += ( *weights_ptr ) * ( *weights_ptr );
2649 chi2Params->
sumWeight[
j] = partialsumWeightp;
2683 REAL8 sumWeightSquare, meanN, sigmaN;
2685 REAL8 nj, sumWeightj, sumWeightSquarej;
2691 FILE *fpChi2 = NULL;
2696 REAL8 numberCountTotal;
2720 weightsV.
length = mObsCoh;
2734 numberCountV.
data = NULL;
2749 fpChi2 = fopen(
"hough_top.dat",
"w" );
2751 snprintf(
path,
sizeof(
path ),
"houghtop_chi2_%d_%d.dat", skyCounter + 1, nSkyPatches );
2752 fpChi2 = fopen(
path,
"w" );
2758 for (
i = 0;
i < tl->
elems;
i++ ) {
2763 pulsarTemplate.
f0 = readTopList.
Freq ;
2767 oldSig = readTopList.
Fstat;
2770 memcpy( weightsV.
data, weightsNoise->
data, mObsCoh *
sizeof(
REAL8 ) );
2782 sumWeightSquare = 0.0;
2784 for (
k = 0;
k < (
UINT4 )mObsCoh;
k++ ) {
2785 sumWeightSquare += weightsV.
data[
k] * weightsV.
data[
k];
2788 meanN = mObsCoh * alphaPeak;
2789 sigmaN = sqrt( sumWeightSquare * alphaPeak * ( 1.0 - alphaPeak ) );
2808 for ( ii = 0 ; ( ii < numberSFTp ) ; ii++ ) {
2810 ind = floor( foft.
data[
j] * timeBase - sftFminBin + 0.5 );
2818 numberCountV.
data[
k] = numberCount;
2826 numberCountTotal = 0;
2830 numberCountTotal += numberCountV.
data[
k];
2833 eta = numberCountTotal / mObsCoh;
2835 for (
j = 0 ;
j < ( (
UINT4 )
p ) ;
j++ ) {
2837 nj = numberCountV.
data[
j];
2841 chi2 += ( nj - sumWeightj *
eta ) * ( nj - sumWeightj *
eta ) / ( sumWeightSquarej *
eta * ( 1 -
eta ) );
2844 setvbuf( fpChi2, (
char * )NULL, _IOLBF, 0 );
2845 fprintf( fpChi2,
"%.13g %.7g %.7g %.5g %.6g %.6g %.7g \n", pulsarTemplate.
f0, pulsarTemplate.
longitude, pulsarTemplate.
latitude, pulsarTemplate.
spindown.
data[0], ( numberCountTotal - meanN ) / sigmaN, oldSig,
chi2 );
2858 weightsV.
data = NULL;
2884 UINT4 iIFO, iSFT, numsft, numifo,
j, binsSFT;
2893 for (
j = 0, iIFO = 0; iIFO < numifo; iIFO++ ) {
2897 for ( iSFT = 0; iSFT < numsft; iSFT++,
j++ ) {
2911 out->pg[
j].length = nPeaks;
2912 out->pg[
j].peak = NULL;
void InitDopplerSkyScan(LALStatus *status, DopplerSkyScanState *skyScan, const DopplerSkyScanInit *init)
void FreeDopplerSkyScan(LALStatus *status, DopplerSkyScanState *skyScan)
int XLALNextDopplerSkyPos(PulsarDopplerParams *pos, DopplerSkyScanState *skyScan)
NextDopplerSkyPos(): step through sky-grid return 0 = OK, -1 = ERROR.
@ STATE_FINISHED
all templates have been read
@ GRID_ISOTROPIC
approximately isotropic sky-grid
Header file for non-demodulated Hough search.
#define DRIVEHOUGHCOLOR_ENONULL
#define DRIVEHOUGHCOLOR_MSGEBAD
#define DRIVEHOUGHCOLOR_MSGENULL
#define DRIVEHOUGHCOLOR_EFILE
#define DRIVEHOUGHCOLOR_ENULL
#define DRIVEHOUGHCOLOR_EBAD
#define DRIVEHOUGHCOLOR_MSGEFILE
#define DRIVEHOUGHCOLOR_MSGENONULL
void ComputeandPrintChi2(LALStatus *status, toplist_t *tl, REAL8Vector *timeDiffV, REAL8Cart3CoorVector *velV, INT4 skyCounter, INT4 nSkyPatches, INT4 p, REAL8 alphaPeak, MultiDetectorStateSeries *mdetStates, REAL8Vector *weightsNoise, UCHARPeakGramVector *upgV)
int main(int argc, char *argv[])
int PrintExtraInfo(CHAR *fileMaps, FILE **fp1_ptr, INT4 iHmap, HOUGHMapTotal *ht, REAL8UnitPolarCoor *sourceLocation, HoughStats *stats, INT8 fBinSearch, REAL8 deltaF)
Print some extra information: HoughMaps, HoughStatistics, sigma.
void SplitSFTs(LALStatus *status, REAL8Vector *weightsV, HoughParamsTest *chi2Params)
BOOLEAN uvar_EnableToplistPatch
void GetPeakGramFromMultSFTVector_NondestroyPg1(LALStatus *status, HOUGHPeakGramVector *out, UCHARPeakGramVector *upgV, MultiSFTVector *in, REAL8 thr)
Loop over SFTs and set a threshold to get peakgrams.
void SelectBestStuff(LALStatus *status, BestVariables *out, BestVariables *in, UINT4 mObsCohBest)
void GetToplistFromHoughmap(LALStatus *status, toplist_t *list, HOUGHMapTotal *ht, HOUGHPatchGrid *patch, HOUGHDemodPar *parDem, REAL8 mean, REAL8 sigma)
Get Hough candidates as a toplist.
void GetAMWeights(LALStatus *status, REAL8Vector *out, MultiDetectorStateSeries *mdetStates, REAL8 alpha, REAL8 delta)
void SetUpSkyPatches(LALStatus *status, HoughSkyPatchesInfo *out, CHAR *skyFileName, CHAR *skyRegion, REAL8 dAlpha, REAL8 dDelta, INT4 numSkyPartitions, INT4 partitionIndex)
Set up location of skypatch centers and sizes If user specified skyRegion then use DopplerScan functi...
int OpenExtraInfoFiles(CHAR *fileMaps, FILE **fp1_ptr, CHAR *filehisto, CHAR *dirname, CHAR *basename, INT4 ind)
void DuplicateBestStuff(LALStatus *status, BestVariables *out, BestVariables *in)
void GetPeakGramFromMultSFTVector(LALStatus *status, HOUGHPeakGramVector *out, MultiSFTVector *in, REAL8 thr)
Loop over SFTs and set a threshold to get peakgrams.
void LALHOUGHDestroyLUTs(LALStatus *status, HOUGHptfLUTVector *lut)
void LALHOUGHCreatePHMDVS(LALStatus *status, PHMDVectorSequence *phmdVS, UINT4 length, UINT4 nfSize)
void LALHOUGHCreateLUTs(LALStatus *status, HOUGHptfLUTVector *lutV, UINT2 maxNBins, UINT2 maxNBorders, UINT2 ySide)
void LALHOUGHCreateHT(LALStatus *status, HOUGHMapTotal *ht, UINT2 xSide, UINT2 ySide)
void LALHoughHistogramSignificance(LALStatus *status, UINT8Vector *out, HOUGHMapTotal *in, REAL8 mean, REAL8 sigma, REAL8 minSignificance, REAL8 maxSignificance)
given a total hough map, this function produces a histogram of the number count significance
void LALHOUGHDestroyPHMDs(LALStatus *status, PHMDVectorSequence *phmdVS)
int CreateSkypatchDirs(CHAR *filestats, CHAR *base, INT4 ind)
void ReadTimeStampsFile(LALStatus *status, LIGOTimeGPSVector *ts, CHAR *filename)
int PrintHmap2m_file(HOUGHMapTotal *ht, CHAR *fnameOut, INT4 iHmap)
void PrintLogFile(LALStatus *status, CHAR *dir, CHAR *basename, CHAR *skyfile, LALStringVector *linefiles, CHAR *executable)
#define HOUGHMAXFILENAMELENGTH
BOOLEAN uvar_EnableExtraInfo
int PrintHistogram(UINT8Vector *hist, CHAR *fnameOut, REAL8 minSignificance, REAL8 maxSignificance)
void ComputeFoft_NM(LALStatus *status, REAL8Vector *foft, HoughTemplate *pulsarTemplate, REAL8Vector *timeDiffV, REAL8Cart3CoorVector *velV)
void LALHOUGHCreatePHMDs(LALStatus *status, PHMDVectorSequence *phmdVS, UINT2 maxNBins, UINT2 maxNBorders, UINT2 ySide)
void GetSFTNoiseWeights(LALStatus *status, REAL8Vector *out, MultiNoiseWeights *in)
int PrintHmap2file(HOUGHMapTotal *ht, CHAR *fnameOut, INT4 iHmap)
void LALHOUGHCreateLUTVector(LALStatus *status, HOUGHptfLUTVector *lutV, UINT4 length)
helper function for creating LUT vector
void GetSFTVelTime(LALStatus *status, REAL8Cart3CoorVector *velV, LIGOTimeGPSVector *timeV, MultiDetectorStateSeries *in)
void LALHOUGHCreateFreqIndVector(LALStatus *status, UINT8FrequencyIndexVector *freqInd, UINT4 length, REAL8 deltaF)
void sort_fstat_toplist(toplist_t *l)
sorts the toplist with an internal sorting function, used before finally writing it
void free_fstat_toplist(toplist_t **l)
frees the space occupied by the toplist
int create_fstat_toplist(toplist_t **tl, UINT8 length)
creates a toplist with length elements, returns -1 on error (usually out of memory),...
int write_fstat_toplist_to_fp(toplist_t *tl, FILE *fp, UINT4 *checksum)
Writes the toplist to an (already open) filepointer Returns the number of written charactes sets the ...
int insert_into_fstat_toplist(toplist_t *tl, FstatOutputEntry elem)
Inserts an element in to the toplist either if there is space left or the element is larger than the ...
lal_errhandler_t lal_errhandler
int LAL_ERR_EXIT(LALStatus *stat, const char *func, const char *file, const int line, volatile const char *id)
#define LAL_CALL(function, statusptr)
void LALCheckMemoryLeaks(void)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
static double double delta
#define ABORT(statusptr, code, mesg)
#define XLAL_CHECK_LAL(sp, assertion,...)
#define TRY(func, statusptr)
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
void LALUCHAR2HOUGHPeak(LALStatus *status, HOUGHPeakGram *pgOut, UCHARPeakGram *pgIn)
Compress explicit peak gram.
void SFTtoUCHARPeakGram(LALStatus *status, UCHARPeakGram *pg, const SFTtype *sft, REAL8 thr)
Convert a normalized sft into a peakgram by selecting bins in which power exceeds a threshold.
void XLALDestroyMultiDetectorStateSeries(MultiDetectorStateSeries *mdetStates)
Helper function to get rid of a multi-IFO DetectorStateSeries Note, this is "NULL-robust" in the sens...
MultiDetectorStateSeries * XLALGetMultiDetectorStatesFromMultiSFTs(const MultiSFTVector *multiSFTs, const EphemerisData *edat, REAL8 tOffset)
Get the 'detector state' (ie detector-tensor, position, velocity, etc) for the given multi-vector of ...
void LALStereo2SkyLocation(LALStatus *status, REAL8UnitPolarCoor *sourceLocation, UINT2 xPos, UINT2 yPos, HOUGHPatchGrid *patch, HOUGHDemodPar *parDem)
Find source sky location given stereographic coordinates indexes.
REAL8 HoughTT
Total Hough Map pixel type.
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.
MultiAMCoeffs * XLALComputeMultiAMCoeffs(const MultiDetectorStateSeries *multiDetStates, const MultiNoiseWeights *multiWeights, SkyPosition skypos)
Multi-IFO version of XLALComputeAMCoeffs().
#define XLAL_INIT_DECL(var,...)
void LALHOUGHConstructHMT_W(LALStatus *status, HOUGHMapTotal *ht, UINT8FrequencyIndexVector *freqInd, PHMDVectorSequence *phmdVS)
Calculates the total hough map for a given trajectory in the time-frequency plane and a set of partia...
void LALHOUGHConstructSpacePHMD(LALStatus *status, PHMDVectorSequence *phmdVS, HOUGHPeakGramVector *pgV, HOUGHptfLUTVector *lutV)
constructs the space of phmd PHMDVectorSequence *phmdVS, given a HOUGHPeakGramVector *pgV and HOUGHpt...
void LALHOUGHNormalizeWeights(LALStatus *status, REAL8Vector *weightV)
Normalizes weight factors so that their sum is N.
void LALHOUGHWeighSpacePHMD(LALStatus *status, PHMDVectorSequence *phmdVS, REAL8Vector *weightV)
Adds weight factors for set of partial hough map derivatives – the weights must be calculated outside...
void LALHOUGHInitializeWeights(LALStatus *status, REAL8Vector *weightV)
Initializes weight factors to unity.
void LALHOUGHupdateSpacePHMDup(LALStatus *status, PHMDVectorSequence *phmdVS, HOUGHPeakGramVector *pgV, HOUGHptfLUTVector *lutV)
This function updates the space of phmd increasing the frequency phmdVS->fBinMin by one.
void LALHOUGHConstructHMT(LALStatus *status, HOUGHMapTotal *ht, UINT8FrequencyIndexVector *freqInd, PHMDVectorSequence *phmdVS)
Given PHMDVectorSequence *phmdVS, the space of phmd, and UINT8FrequencyIndexVector *freqInd,...
void LALNDHOUGHParamPLUT(LALStatus *status, HOUGHParamPLUT *out, HOUGHSizePar *sizePar, HOUGHDemodPar *par)
#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 LALHOUGHComputeNDSizePar(LALStatus *status, HOUGHSizePar *out, HOUGHResolutionPar *in)
void LALHOUGHFillPatchGrid(LALStatus *status, HOUGHPatchGrid *out, HOUGHSizePar *par)
void LALHOUGHConstructPLUT(LALStatus *status, HOUGHptfLUT *lut, HOUGHPatchGrid *patch, HOUGHParamPLUT *par)
INT2 COORType
To be changed to {INT2 COORType} if the number of pixels in the x-direction exceeds 255.
void void LogPrintfVerbatim(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
void LogPrintf(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
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.
MultiNoiseWeights * XLALComputeMultiNoiseWeights(const MultiPSDVector *rngmed, UINT4 blocksRngMed, UINT4 excludePercentile)
Computes weight factors arising from MultiSFTs with different noise floors.
void XLALDestroyMultiNoiseWeights(MultiNoiseWeights *weights)
Destroy a MultiNoiseWeights object.
void LALCreateRandomParams(LALStatus *status, RandomParams **params, INT4 seed)
void LALDestroyRandomParams(LALStatus *status, RandomParams **params)
void LALRemoveKnownLinesInMultiSFTVector(LALStatus *status, MultiSFTVector *MultiSFTVect, INT4 width, INT4 window, LALStringVector *linefiles, RandomParams *randPar)
top level function to remove lines from a multi sft vector given a list of files containing list of k...
void XLALDestroySFTCatalog(SFTCatalog *catalog)
Free an 'SFT-catalogue'.
MultiSFTVector * XLALLoadMultiSFTs(const SFTCatalog *inputCatalog, REAL8 fMin, REAL8 fMax)
Function to load a catalog of SFTs from possibly different detectors.
void XLALDestroyMultiSFTVector(MultiSFTVector *multvect)
Destroy a multi SFT-vector.
LIGOTimeGPSVector * XLALCreateTimestampVector(UINT4 len)
Allocate a LIGOTimeGPSVector.
SFTCatalog * XLALSFTdataFind(const CHAR *file_pattern, const SFTConstraints *constraints)
Find the list of SFTs matching the file_pattern and satisfying the given constraints,...
void XLALDestroyTimestampVector(LIGOTimeGPSVector *vect)
De-allocate a LIGOTimeGPSVector.
COORDINATESYSTEM_EQUATORIAL
void LALHoughStatistics(LALStatus *status, HoughStats *out, HOUGHMapTotal *in)
This function calculates the maximum number count, minimum number count, average and standard deviati...
void XLALDestroyUINT8Vector(UINT8Vector *vector)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
UINT8Vector * XLALCreateUINT8Vector(UINT4 length)
#define XLAL_CHECK_MAIN(assertion,...)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
REAL8 XLALGPSDiff(const LIGOTimeGPS *t1, const LIGOTimeGPS *t0)
p
RUN ANALYSIS SCRIPT ###.
#define MAXFILENAMELENGTH
REAL4Vector * b
(weighted) per-SFT antenna-pattern function
REAL4Vector * a
(weighted) per-SFT antenna-pattern function
struct fo storing all the variables affected by the selection of a subset of SFTs
REAL8Vector * timeDiffV
the vector of time diffs
HOUGHPeakGramVector * pgV
the vector of peakgrams
REAL8Vector * weightsV
noise and AM weights
REAL8Cart3CoorVector * velV
vector of detector velocities
UINT4 length
the number of SFTs to be selected
COMPLEX8FrequencySeries * data
Pointer to the data array.
UINT4 length
Number of elements in array.
LIGOTimeGPS tGPS
GPS timestamps corresponding to this entry.
DetectorState * data
array of DetectorState entries
UINT4 length
total number of entries
initialization-structure passed to InitDopplerSkyScan()
this structure reflects the current state of a DopplerSkyScan
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
Type to hold the fields that will be output in unclustered output file
REAL8 Alpha
Skyposition: longitude in equatorial coords, radians.
REAL8 Delta
skyposition: latitude
REAL8 Freq
Frequency at maximum (?) of the cluster.
REAL8 f1dot
spindown value f1dot = df/dt
This structure stores the border indexes corresponding to one frequency bin plus the corrections to b...
This structure stores the border of a circle clipped on the projected plane.
COORType * xPixel
x pixel index to be marked
UINT2 ySide
length of xPixel
Demodulation parameters needed for the Hough transform; all coordinates are assumed to be with respec...
REAL8Cart3Coor positC
(x,y,z): Position of the detector
REAL8 deltaF
Frequency resolution: df=1/TCOH
REAL8 timeDiff
: time difference
REAL8Cart3Coor veloC
(x,y,z): Relative detector velocity
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 spinRes
Refined spin parameters used in the Hough transform.
INT8 f0Bin
frequency bin for which it has been constructed
UINT4 mObsCoh
ratio of observation time and coherent timescale
REAL8 deltaF
frequency resolution
Parameters needed to construct the partial look up table.
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.
This structure stores the `‘peak-gram’'.
INT4 * peak
The peak indices relative to fBinIni, i.e., the zero peak corresponds to fBinIni.
This structure contains a vector of peak-grams (for the different time stamps)
UINT4 length
number of elements
HOUGHPeakGram * pg
the Peakgrams
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 maxNBorders
maximum number of borders affecting the patch; for memory allocation
UINT2 maxNBins
maximum number of bins affecting the patch; for memory allocation
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)
This structure stores a partial Hough map derivative.
UCHAR * firstColumn
Number of elements of firstColumn.
UINT2 ySide
number of elements of firstColumn
HOUGHBorder ** rightBorderP
Pointers to borders.
UINT2 maxNBorders
Maximun number of borders of each type (for memory allocation purposes), i.e. length of *leftBorderP ...
HOUGHBorder ** leftBorderP
Pointers to borders.
This structure stores the patch-time-frequency look up table.
UINT2 maxNBins
Maximum number of bins affecting the patch (for memory allocation purposes)
HOUGHBorder * border
The annulus borders.
HOUGHBin2Border * bin
Bin to border correspondence.
UINT2 maxNBorders
Maximum number of borders affecting the patch (for memory allocation purposes)
This structure contains a vector of partial look up tables (for the different time stamps)
HOUGHptfLUT * lut
the partial Look Up Tables
UINT4 length
number of elements
HoughSignificantEvent * event
Structure for storing statistical information about a Hough map.
A vector of 'timestamps' of type LIGOTimeGPS.
LIGOTimeGPS * data
array of timestamps
UINT4 length
number of timestamps
Multi-IFO container for antenna-pattern coefficients and atenna-pattern matrix .
AMCoeffs ** data
noise-weighted AM-coeffs , and
Multi-IFO time-series of DetectorStates.
UINT4 length
number of detectors
DetectorStateSeries ** data
vector of pointers to DetectorStateSeries
One noise-weight (number) per SFT (therefore indexed over IFOs and SFTs.
UINT4 length
number of detectors
REAL8Vector ** data
weights-vector for each detector
A collection of PSD vectors – one for each IFO in a multi-IFO search.
A collection of SFT vectors – one for each IFO in a multi-IFO search.
UINT4 length
number of ifos
SFTVector ** data
sftvector for each ifo
This structure contains a vector sequence of partial-Hough maps derivatives (for different time stamp...
UINT8 fBinMin
frequency index of smallest intrinsic frequency in circular buffer
UINT4 nfSize
number of different frequencies
REAL8 deltaF
frequency resolution
HOUGHphmd * phmd
the partial Hough map derivatives
UINT4 length
number of elements for each frequency
Type containing the 'Doppler-parameters' affecting the time-evolution of the phase.
REAL8 Delta
Sky position: DEC (latitude) in equatorial coords and radians.
REAL8 Alpha
Sky position: RA (longitude) in equatorial coords and radians.
Three dimensional Cartessian coordinates.
REAL8Cart3Coor * data
x.y.z
UINT4 length
number of elements
Polar coordinates of a unitary vector on the sphere.
REAL8 delta
In the interval [ ].
An "SFT-catalogue": a vector of SFTdescriptors, as returned by XLALSFTdataFind()
SFTDescriptor * data
array of data-entries describing matched SFTs
UINT4 length
number of SFTs in catalog
'Constraints' for SFT-matching: which detector, within which time-stretch and which timestamps exactl...
CHAR * detector
2-char channel-prefix describing the detector (eg 'H1', 'H2', 'L1', 'G1' etc)
LIGOTimeGPSVector * timestamps
list of timestamps
LIGOTimeGPS * maxStartTime
only include SFTs whose epoch is < maxStartTime
LIGOTimeGPS * minStartTime
only include SFTs whose epoch is >= minStartTime
SFTtype header
SFT-header info.
Explicit peakgram structure – 1 if power in bin is above threshold and 0 if below.
UCHAR * data
pointer to the data {0,1}
REAL8 timeBase
coherent time baseline used to construct peakgram
INT4 nPeaks
number of peaks selected in data
INT4 length
number of elements in data
INT4 fminBinIndex
first frequency bin of peakgram
UCHARPeakGram * upg
expanded Peakgrams
UINT4 length
number of elements
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