29 #include <lal/LALComputeAM.h>
30 #include <lal/ComputeSky.h>
31 #include <gsl/gsl_cdf.h>
34 #define EARTHEPHEMERIS ".earth00-40-DE405.dat"
35 #define SUNEPHEMERIS "sun00-40-DE405.dat"
37 #define MAXFILENAMELENGTH 256
41 #define BLOCKSRNGMED 101
54 #define SFTDIRECTORY "/local_data/badkri/fakesfts/"
55 #define FILEOUT "./ValidateAMOut"
59 int main(
int argc,
char *argv[] )
88 CHAR *fnamelog = NULL;
94 REAL8 numberCount2, numberCount1;
95 REAL8 nth1, nth2, erfcInv;
97 REAL8 mean1, mean2, var1, var2, sumsq, peakprob;
112 REAL8 uvar_houghFalseAlarm;
113 REAL8 uvar_peakThreshold;
116 REAL8 uvar_mismatchW;
117 CHAR *uvar_earthEphemeris = NULL;
118 CHAR *uvar_sunEphemeris = NULL;
120 CHAR *uvar_fnameout = NULL;
134 uvar_mismatchW = 0.0;
135 uvar_houghFalseAlarm = 1.0e-10;
158 strcpy( uvar_fnameout,
FILEOUT );
190 strcpy( fnamelog, uvar_fnameout );
191 strcat( fnamelog,
"_log" );
193 if ( ( fpLog = fopen( fnamelog,
"w" ) ) == NULL ) {
194 fprintf( stderr,
"Unable to open file %s for writing\n", fnamelog );
202 fprintf( fpLog,
"## Log file for HoughValidateAM \n\n" );
203 fprintf( fpLog,
"# User Input:\n" );
204 fprintf( fpLog,
"#-------------------------------------------\n" );
205 fprintf( fpLog,
"%s", logstr );
210 CHAR command[1024] =
"";
211 fprintf( fpLog,
"\n\n# CVS-versions of executable:\n" );
212 fprintf( fpLog,
"# -----------------------------------------\n" );
215 sprintf( command,
"ident %s | sort -u >> %s", argv[0], fnamelog );
219 if ( system( command ) ) {
220 fprintf( stderr,
"\nsystem('%s') returned non-zero status!\n\n", command );
229 threshold = uvar_peakThreshold / normalizeThr;
233 if ( uvar_ifo == 1 ) {
236 if ( uvar_ifo == 2 ) {
239 if ( uvar_ifo == 3 ) {
249 pulsarInject.
aPlus = 0.5 * uvar_h0 * ( 1.0 + uvar_cosiota * uvar_cosiota );
250 pulsarInject.
aCross = uvar_h0 * uvar_cosiota;
252 pulsarInject.
phi0 = uvar_phi0;
262 pulsarTemplate.
latitude = uvar_delta;
282 strcat( tempDir,
"/*SFT*.*" );
296 mObsCoh = inputSFTs->
length;
300 sftFminBin = floor( timeBase * inputSFTs->
data->
f0 + 0.5 );
303 fHeterodyne = sftFminBin *
deltaF;
304 tSamplingRate = 2.0 *
deltaF * ( sftlength - 1. );
318 sft = inputSFTs->
data;
319 for (
i = 0;
i < mObsCoh;
i++ ) {
328 timeDiffV.
length = mObsCoh;
329 timeDiffV.
data = NULL;
336 midTimeBase = 0.5 * timeBase;
340 timeDiffV.
data[0] = midTimeBase;
342 for (
j = 1;
j < mObsCoh; ++
j ) {
345 timeDiffV.
data[
j] =
ts + tn -
t0 + midTimeBase;
361 velPar.
tBase = timeBase;
390 uvar_alpha + uvar_mismatchW,
391 uvar_delta + uvar_mismatchW ), &
status );
396 peakprob = exp( -uvar_peakThreshold );
397 erfcInv = gsl_cdf_ugaussian_Qinv( uvar_houghFalseAlarm ) / sqrt( 2 );
402 mean1 = mObsCoh * peakprob;
403 var1 = mObsCoh * peakprob * ( 1 - peakprob );
404 nth1 = mean1 + sqrt( 2.0 * var1 ) * erfcInv;
411 for (
j = 0;
j < mObsCoh;
j++ ) {
413 tempW = weight->
data[
j];
414 sumsq += tempW * tempW;
416 var2 = sumsq * peakprob * ( 1 - peakprob );
417 nth2 = mean2 + sqrt( 2.0 * var2 ) * erfcInv;
483 sftParams.
Tsft = timeBase;
495 params.samplingRate = tSamplingRate;
496 params.fHeterodyne = fHeterodyne;
522 for ( mmT = 0; mmT <= 0; mmT++ ) {
523 for ( mmP = 0; mmP <= 0; mmP++ ) {
528 pulsarTemplate1.
f0 = pulsarTemplate.
f0 ;
529 pulsarTemplate1.
latitude = pulsarTemplate.
latitude + mmFactor * mmT * deltaTheta;
539 for (
j = 0;
j < mObsCoh;
j++ ) {
567 ind = floor( foft.
data[
j] * timeBase - sftFminBin + 0.5 );
569 tempW = weight->
data[
j];
570 numberCount1 += pg1.
data[ind];
571 numberCount2 += tempW * pg1.
data[ind];
579 fprintf( stdout,
"%g %g %g %g %g %g %g %g %g %g %g\n",
580 uvar_alpha, uvar_delta, uvar_cosiota, mean1, var1, nth1, numberCount1, mean2, var2, nth2, numberCount2 );
612 signalTseries = NULL;
657 REAL8 f0new, vcProdn, timeDiffN;
659 REAL8 sourceDelta, sourceAlpha, cosDelta;
660 INT4 j,
i, nspin, factorialN;
677 sourceDelta = pulsarTemplate->
latitude;
679 cosDelta = cos( sourceDelta );
681 sourceLocation.
x = cosDelta * cos( sourceAlpha );
682 sourceLocation.
y = cosDelta * sin( sourceAlpha );
683 sourceLocation.
z = sin( sourceDelta );
688 for (
j = 0;
j < mObsCoh; ++
j ) {
689 vcProdn = velV->
data[
j].
x * sourceLocation.
x
690 + velV->
data[
j].
y * sourceLocation.
y
691 + velV->
data[
j].
z * sourceLocation.
z;
692 f0new = pulsarTemplate->
f0;
694 timeDiffN = timeDiffV->
data[
j];
696 for (
i = 0;
i < nspin; ++
i ) {
697 factorialN *= (
i + 1 );
698 f0new += pulsarTemplate->
spindown.
data[
i] * timeDiffN / factorialN;
699 timeDiffN *= timeDiffN;
701 f0newBin = floor( f0new * timeBase + 0.5 );
702 foft->
data[
j] = f0newBin * ( 1.0 + vcProdn ) / timeBase;
LALDetectorIndexGEO600DIFF
#define DRIVEHOUGHCOLOR_MSGENULL
#define DRIVEHOUGHCOLOR_ENULL
#define DRIVEHOUGHCOLOR_MSGENORM
#define DRIVEHOUGHCOLOR_ENORM
int main(int argc, char *argv[])
void ComputeFoft(LALStatus *status, REAL8Vector *foft, HoughTemplate *pulsarTemplate, REAL8Vector *timeDiffV, REAL8Cart3CoorVector *velV, REAL8 timeBase)
#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 LALSelectPeakColorNoise(LALStatus *status, UCHARPeakGram *pg, REAL8 *thr, REAL8PeriodoPSD *in)
Function for selecting peaks in colored noise – obsolete – use LAL functions in NormalizeSFTRngMed....
void LALPeriodo2PSDrng(LALStatus *status, REAL8Periodogram1 *psd, REAL8Periodogram1 *peri, INT4 *blocksRNG)
Wrapper for LALRunningMedian code – obsolete – use LAL functions in NormalizeSFTRngMed....
void COMPLEX8SFT2Periodogram1(LALStatus *status, REAL8Periodogram1 *peri, COMPLEX8SFTData1 *sft)
OBSOLETE – Use LAL functions from SFTfileIO.c instead.
const LALDetector lalCachedDetectors[LAL_NUM_DETECTORS]
void LALGeneratePulsarSignal(LALStatus *status, REAL4TimeSeries **signalvec, const PulsarSignalParams *params)
void LALSignalToSFTs(LALStatus *status, SFTVector **outputSFTs, const REAL4TimeSeries *signalvec, const SFTParams *params)
void XLALDestroyEphemerisData(EphemerisData *edat)
Destructor for EphemerisData struct, NULL robust.
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 LALHOUGHNormalizeWeights(LALStatus *status, REAL8Vector *weightV)
Normalizes weight factors so that their sum is N.
void LALHOUGHComputeAMWeights(LALStatus *status, REAL8Vector *weightV, LIGOTimeGPSVector *timeV, LALDetector *detector, EphemerisData *edat, REAL8 alpha, REAL8 delta)
Computes weight factors arising from amplitude modulation – it multiplies an existing weight vector.
void LALHOUGHInitializeWeights(LALStatus *status, REAL8Vector *weightV)
Initializes weight factors to unity.
#define VTOT
Total detector velocity/c TO BE CHANGED DEPENDING ON DETECTOR.
void LALRngMedBias(LALStatus *status, REAL8 *biasFactor, INT4 blkSize)
void XLALDestroySFTVector(SFTVector *vect)
XLAL interface to destroy an SFTVector.
SFTVector * XLALLoadSFTs(const SFTCatalog *catalog, REAL8 fMin, REAL8 fMax)
Load the given frequency-band [fMin, fMax) (half-open) from the SFT-files listed in the SFT-'catalogu...
SFTCatalog * XLALSFTdataFind(const CHAR *file_pattern, const SFTConstraints *constraints)
Find the list of SFTs matching the file_pattern and satisfying the given constraints,...
COORDINATESYSTEM_EQUATORIAL
void LALDCreateVector(LALStatus *, REAL8Vector **, UINT4)
void LALDDestroyVector(LALStatus *, REAL8Vector **)
void LALAvgDetectorVel(LALStatus *status, REAL8 v[3], VelocityPar *in)
This function outputs the average velocity REAL8 v[3] of the detector during a time interval.
#define XLAL_CHECK_MAIN(assertion,...)
A vector of COMPLEX8FrequencySeries.
COMPLEX8FrequencySeries * data
Pointer to the data array.
UINT4 length
Number of elements in array.
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
Input parameters to GeneratePulsarSignal(), defining the source and the time-series.
Three dimensional Cartessian coordinates.
REAL8Cart3Coor * data
x.y.z
UINT4 length
number of elements
structure containing psd and periodogram of a sft – obsolete – use LAL functions
REAL8Periodogram1 periodogram
An "SFT-catalogue": a vector of SFTdescriptors, as returned by XLALSFTdataFind()
SFTDescriptor * data
array of data-entries describing matched SFTs
SFTtype header
SFT-header info.
Parameters defining the SFTs to be returned from LALSignalToSFTs().
REAL8 Tsft
length of each SFT in seconds
const LIGOTimeGPSVector * timestamps
timestamps to produce SFTs for (can be NULL)
const SFTVector * noiseSFTs
noise SFTs to be added (can be NULL)
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
This structure stores the parameters required by XLALBarycenter() to calculate Earth velocity at a gi...
EphemerisData * edat
ephemeris data pointer from XLALInitBarycenter()
LALDetector detector
the detector
REAL8 tBase
duration of interval
LIGOTimeGPS startTime
start of time interval
REAL8 vTol
fractional accuracy required for velocity (redundant for average velocity calculation)