43#define EARTHEPHEMERIS "/home/llucia/chi2/earth05-09.dat"
44#define SUNEPHEMERIS "/home/llucia/chi2/sun05-09.dat"
46#define MAXFILENAMELENGTH 512
48#define DIROUT "./outMultiChi2Test"
49#define BASENAMEOUT "HM"
53#define FALSEALARM 1.0e-9
54#define SKYFILE "./skypatchfile"
58#define BLOCKSRNGMED 101
66#define SFTDIRECTORY "/local_data/sintes/SFT-S5-120-130/*SFT*.*"
76typedef struct tagHoughParamsTest {
80 REAL8 *sumWeightSquare;
94int main(
int argc,
char *argv[] )
137 REAL8 numberCountTotal;
145 REAL8 alphaPeak, meanN, sigmaN;
148 BOOLEAN uvar_weighAM, uvar_weighNoise;
151 REAL8 uvar_fStart, uvar_peakThreshold, uvar_fSearchBand;
153 REAL8 uvar_AlphaWeight, uvar_DeltaWeight;
154 CHAR *uvar_earthEphemeris = NULL;
155 CHAR *uvar_sunEphemeris = NULL;
157 CHAR *uvar_timeStampsFile = NULL;
158 CHAR *uvar_outfile = NULL;
169 uvar_weighNoise =
TRUE;
171 uvar_nfSizeCylinder =
NFSIZE;
173 uvar_fSearchBand =
FBAND;
175 uvar_maxBinsClean = 100;
184 uvar_AlphaWeight = uvar_Alpha;
185 uvar_DeltaWeight = uvar_Delta;
188 chi2Params.
length = uvar_p;
194 strcpy( uvar_outfile,
"./tempout" );
219 " - '<SFT file>;<SFT file>;...', where <SFT file> may contain wildcards\n - 'list:<file containing list of SFT files>'" ) ==
XLAL_SUCCESS,
XLAL_EFUNC );
247 if ( uvar_fStart < 0 ) {
248 fprintf( stderr,
"start frequency must be positive\n" );
252 if ( uvar_fSearchBand < 0 ) {
253 fprintf( stderr,
"search frequency band must be positive\n" );
257 if ( uvar_peakThreshold < 0 ) {
258 fprintf( stderr,
"peak selection threshold must be positive\n" );
265 chi2Params.
length = uvar_p;
294 constraints.
timestamps = inputTimeStampsVector;
299 if ( ( catalog == NULL ) || ( catalog->
length == 0 ) ) {
310 mObsCoh = catalog->
length;
331 timeDiffV.
length = mObsCoh;
332 timeDiffV.
data = NULL;
336 doppWings = ( uvar_fStart + uvar_fSearchBand ) *
VTOT;
351 if ( ( fpRand = fopen(
"/dev/urandom",
"r" ) ) == NULL ) {
352 fprintf( stderr,
"Error in opening /dev/urandom" );
356 if ( ( ranCount = fread( &
seed,
sizeof(
seed ), 1, fpRand ) ) != 1 ) {
357 fprintf( stderr,
"Error in getting random seed" );
371 numifo = inputSFTs->
length;
373 sftFminBin = (
INT4 ) floor( inputSFTs->
data[0]->
data[0].
f0 * timeBase + 0.5 );
396 weightsV.
length = mObsCoh;
403 if ( uvar_weighNoise ) {
417 for (
j = 0, iIFO = 0; iIFO < numifo; iIFO++ ) {
421 for ( iSFT = 0; iSFT < numsft; iSFT++,
j++ ) {
427 if ( uvar_weighNoise ) {
438 if ( uvar_weighNoise ) {
443 for (
j = 0;
j < mObsCoh;
j++ ) {
447 if ( uvar_weighNoise ) {
456 if ( uvar_weighAM ) {
469 for (
k = 0, iIFO = 0; iIFO < numifo; iIFO++ ) {
473 for ( iSFT = 0; iSFT < numsft; iSFT++,
k++ ) {
478 b = multiAMcoef->
data[iIFO]->
b->
data[iSFT];
479 weightsV.
data[
k] *= (
a *
a + b * b );
498 pulsarTemplate.
f0 = uvar_Freq;
499 pulsarTemplate.
latitude = uvar_Delta;
513 numberCountV.
length = uvar_p;
514 numberCountV.
data = NULL;
519 UINT4 iIFO, iSFT, ii, numberSFTp;
521 REAL8 sumWeightSquare;
526 sumWeightSquare = 0.0;
527 for (
k = 0;
k < (
INT4 )mObsCoh;
k++ ) {
528 sumWeightSquare += weightsV.
data[
k] * weightsV.
data[
k];
532 alphaPeak = exp( - uvar_peakThreshold );
533 meanN = mObsCoh * alphaPeak;
534 sigmaN = sqrt( sumWeightSquare * alphaPeak * ( 1.0 - alphaPeak ) );
551 for (
k = 0 ;
k < uvar_p ;
k++ ) {
556 for ( ii = 0 ; ( ii < numberSFTp ) && ( iIFO < numifo ) ; ii++ ) {
558 sft = inputSFTs->
data[iIFO]->
data + iSFT;
562 ind = floor( foft.
data[
j] * timeBase - sftFminBin + 0.5 );
564 numberCount += pg1.
data[ind] * weightsV.
data[
j];
570 if ( iSFT >= numsft ) {
574 if ( iIFO < numifo ) {
581 numberCountV.
data[
k] = numberCount;
590 REAL8 nj, sumWeightj, sumWeightSquarej;
593 numberCountTotal = 0;
596 for (
k = 0;
k < uvar_p ;
k++ ) {
597 numberCountTotal += numberCountV.
data[
k];
600 eta = numberCountTotal / mObsCoh;
602 for (
j = 0 ;
j < ( uvar_p ) ;
j++ ) {
604 nj = numberCountV.
data[
j];
608 chi2 += ( nj - sumWeightj *
eta ) * ( nj - sumWeightj *
eta ) / ( sumWeightSquarej *
eta * ( 1 -
eta ) );
615 fp = fopen( uvar_outfile,
"w" );
616 setvbuf(
fp, (
char * )NULL, _IOLBF, 0 );
617 fprintf(
fp,
"%g %g %g %g %g %g %g %g \n", ( numberCountTotal - meanN ) / sigmaN, meanN, sigmaN,
chi2, uvar_Freq, uvar_Alpha, uvar_Delta,
uvar_fdot );
670 REAL8 f0new, vcProdn, timeDiffN;
672 REAL8 sourceDelta, sourceAlpha, cosDelta;
673 INT4 j,
i, nspin, factorialN;
690 sourceDelta = pulsarTemplate->
latitude;
692 cosDelta = cos( sourceDelta );
694 sourceLocation.
x = cosDelta * cos( sourceAlpha );
695 sourceLocation.
y = cosDelta * sin( sourceAlpha );
696 sourceLocation.
z = sin( sourceDelta );
701 for (
j = 0;
j < mObsCoh; ++
j ) {
702 vcProdn = velV->
data[
j].
x * sourceLocation.
x
703 + velV->
data[
j].
y * sourceLocation.
y
704 + velV->
data[
j].
z * sourceLocation.
z;
705 f0new = pulsarTemplate->
f0;
707 timeDiffN = timeDiffV->
data[
j];
709 for (
i = 0;
i < nspin; ++
i ) {
710 factorialN *= (
i + 1 );
711 f0new += pulsarTemplate->
spindown.
data[
i] * timeDiffN / factorialN;
712 timeDiffN *= timeDiffN;
714 f0newBin = floor( f0new * timeBase + 0.5 );
715 foft->
data[
j] = f0newBin * ( 1.0 + vcProdn ) / timeBase;
740 REAL8 partialsumWeightp, partialsumWeightSquarep;
757 mObsCoh = weightsV->
length;
760 sumWeightpMax = (
REAL8 )( mObsCoh ) /
p;
761 weights_ptr = weightsV->
data;
764 for (
j = 0;
j <
p;
j++ ) {
766 partialsumWeightSquarep = 0;
767 partialsumWeightp = 0;
769 for ( numberSFT = 0; ( partialsumWeightp < sumWeightpMax ) && ( iSFT < mObsCoh ); numberSFT++, iSFT++ ) {
771 partialsumWeightp += *weights_ptr;
772 partialsumWeightSquarep += ( *weights_ptr ) * ( *weights_ptr );
Header file for non-demodulated Hough search.
#define DRIVEHOUGHCOLOR_MSGEBAD
#define DRIVEHOUGHCOLOR_MSGENULL
#define DRIVEHOUGHCOLOR_ENULL
#define DRIVEHOUGHCOLOR_EBAD
void REPORTSTATUS(LALStatus *status)
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
#define ATTATCHSTATUSPTR(statusptr)
#define ASSERT(assertion, statusptr, code, mesg)
#define DETATCHSTATUSPTR(statusptr)
#define INITSTATUS(statusptr)
#define RETURN(statusptr)
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.
int main(int argc, char *argv[])
void SplitSFTs(LALStatus *status, REAL8Vector *weightsV, HoughParamsTest *chi2Params)
void ComputeFoft(LALStatus *status, REAL8Vector *foft, HoughTemplate *pulsarTemplate, REAL8Vector *timeDiffV, REAL8Cart3CoorVector *velV, REAL8 timeBase)
BOOLEAN uvar_printTemplates
#define MAXFILENAMELENGTH
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 ...
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().
void LALHOUGHNormalizeWeights(LALStatus *status, REAL8Vector *weightV)
Normalizes weight factors so that their sum is N.
void LALHOUGHInitializeWeights(LALStatus *status, REAL8Vector *weightV)
Initializes weight factors to unity.
#define VTOT
Total detector velocity/c TO BE CHANGED DEPENDING ON DETECTOR.
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.
SFTCatalog * XLALSFTdataFind(const CHAR *file_pattern, const SFTConstraints *constraints)
Find the list of SFTs matching the file_pattern and satisfying the given constraints,...
LIGOTimeGPSVector * XLALReadTimestampsFile(const CHAR *fname)
backwards compatible wrapper to XLALReadTimestampsFileConstrained() without GPS-time constraints
void XLALDestroyTimestampVector(LIGOTimeGPSVector *vect)
De-allocate a LIGOTimeGPSVector.
COORDINATESYSTEM_EQUATORIAL
#define XLAL_CHECK_MAIN(assertion,...)
LIGOTimeGPS * XLALGPSSetREAL8(LIGOTimeGPS *epoch, REAL8 t)
REAL8 XLALGPSDiff(const LIGOTimeGPS *t1, const LIGOTimeGPS *t0)
p
RUN ANALYSIS SCRIPT ###.
REAL4Vector * b
(weighted) per-SFT antenna-pattern function
REAL4Vector * a
(weighted) per-SFT antenna-pattern function
COMPLEX8FrequencySeries * data
Pointer to the data array.
LIGOTimeGPS tGPS
GPS timestamps corresponding to this entry.
DetectorState * data
array of DetectorState entries
UINT4 length
total number of entries
This structure contains all information about the center-of-mass positions of the Earth and Sun,...
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.
DetectorStateSeries ** data
vector of pointers to DetectorStateSeries
One noise-weight (number) per SFT (therefore indexed over IFOs and SFTs.
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
Three dimensional Cartessian coordinates.
REAL8Cart3Coor * data
x.y.z
UINT4 length
number of elements
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}
INT4 length
number of elements in data