Commit 29e3b135 authored by Yuanhao Zhang's avatar Yuanhao Zhang
Browse files

pulsar_crosscorr_v2: used XLALUserVarWasSet check arguements were set, changed...

pulsar_crosscorr_v2: used XLALUserVarWasSet check arguements were set, changed type of sinc-value list from REAL8Vector ->REAL8VectorSequence
Original: e1a96a227c21973e82dc04c2f844a781400776e3
parent 7b4c60f8
......@@ -116,7 +116,7 @@ int main(int argc, char *argv[]){
UINT4Vector *lowestBins = NULL;
REAL8Vector *kappaValues = NULL;
REAL8Vector *signalPhases = NULL;
REAL8Vector *sincValueList = NULL;
REAL8VectorSequence *sincValueList = NULL;
PulsarDopplerParams XLAL_INIT_DECL(dopplerpos);
PulsarDopplerParams thisBinaryTemplate, binaryTemplateSpacings;
......@@ -299,15 +299,18 @@ int main(int argc, char *argv[]){
#define PCC_SFT_HEADER "# The length of SFT list is %u #\n"
FILE *fp = NULL;
if (strcmp(uvar.pairListInputFilename,"")) { /* If the user provided a list for reading, use it */
if (XLALUserVarWasSet(&uvar.pairListInputFilename)) { /* If the user provided a list for reading, use it */
if((sftPairs = XLALCalloc(1, sizeof(sftPairs))) == NULL){
XLAL_ERROR(XLAL_ENOMEM);
}
if((fp = fopen(uvar.pairListInputFilename, "r")) == NULL){
LogPrintf ( LOG_CRITICAL, "didn't find SFT-pair list while readin = TRUE\n", 0);
LogPrintf ( LOG_CRITICAL, "didn't find SFT-pair list file with given input name\n", 0);
XLAL_ERROR( XLAL_EFUNC );
}
fscanf(fp,PCC_SFTPAIR_HEADER,&sftPairs->length);
if(fscanf(fp,PCC_SFTPAIR_HEADER,&sftPairs->length)==EOF){
LogPrintf ( LOG_CRITICAL, "can't read the length of SFT-pair list from the header\n", 0);
XLAL_ERROR( XLAL_EFUNC );
}
/* FIXME: Should check the return value of this */
if((sftPairs->data = XLALCalloc(sftPairs->length, sizeof(*sftPairs->data)))==NULL){
......@@ -316,7 +319,10 @@ int main(int argc, char *argv[]){
}
for(j = 0; j < sftPairs->length; j++){ /*read in the SFT-pair list */
fscanf(fp,"%u %u\n", &sftPairs->data[j].sftNum[0], &sftPairs->data[j].sftNum[1]);
if(fscanf(fp,"%u %u\n", &sftPairs->data[j].sftNum[0], &sftPairs->data[j].sftNum[1])==EOF){
LogPrintf ( LOG_CRITICAL, "The length of SFT-pair list doesn't match!", 0);
XLAL_ERROR( XLAL_EFUNC );
}
/* FIXME: Should check the return value of this */
}
fclose(fp);
......@@ -328,7 +334,7 @@ int main(int argc, char *argv[]){
}
}
if (strcmp(uvar.pairListOutputFilename,"")) { /* Write the list of pairs to a file, if a name was provided */
if (XLALUserVarWasSet(&uvar.pairListOutputFilename)) { /* Write the list of pairs to a file, if a name was provided */
fp = fopen(uvar.pairListOutputFilename,"w");
fprintf(fp,PCC_SFTPAIR_HEADER, sftPairs->length ); /*output the length of SFT-pair list to the header*/
for(j = 0; j < sftPairs->length; j++){
......@@ -337,11 +343,11 @@ int main(int argc, char *argv[]){
fclose(fp);
}
if (strcmp(uvar.sftListOutputFilename,"")) { /* Write the list of SFTs to a file for sanity-checking purposes */
if (XLALUserVarWasSet(&uvar.sftListOutputFilename)) { /* Write the list of SFTs to a file for sanity-checking purposes */
fp = fopen(uvar.sftListOutputFilename,"w");
fprintf(fp,PCC_SFT_HEADER, sftIndices->length ); /*output the length of SFT list to the header*/
for(j = 0; j < sftIndices->length; j++){ /*output the SFT list */
fprintf(fp,"%u %u\n", sftIndices->data[j].detInd, sftIndices->data[j].sftInd);
fprintf(fp,"%u %u \n", sftIndices->data[j].detInd, sftIndices->data[j].sftInd );
}
fclose(fp);
}
......@@ -450,7 +456,7 @@ int main(int argc, char *argv[]){
LogPrintf ( LOG_CRITICAL, "%s: XLALCreateREAL8Vector() failed with errno=%d\n", __func__, xlalErrno );
XLAL_ERROR( XLAL_EFUNC );
}
if ((sincValueList = XLALCreateREAL8Vector ( numSFTs ) ) == NULL){
if ((sincValueList = XLALCreateREAL8VectorSequence ( numSFTs * uvar.numBins, uvar.numBins ) ) == NULL){
LogPrintf ( LOG_CRITICAL, "%s: XLALCreateREAL8Vector() failed with errno=%d\n", __func__, xlalErrno );
XLAL_ERROR( XLAL_EFUNC );
}
......@@ -507,7 +513,7 @@ int main(int argc, char *argv[]){
XLALDestroyREAL8Vector ( kappaValues );
XLALDestroyUINT4Vector ( lowestBins );
XLALDestroyREAL8Vector ( shiftedFreqs );
XLALDestroyREAL8Vector ( sincValueList );
XLALDestroyREAL8VectorSequence ( sincValueList );
XLALDestroyMultiSSBtimes ( multiBinaryTimes );
XLALDestroyMultiSSBtimes ( multiSSBTimes );
XLALDestroyREAL8Vector ( curlyGUnshifted );
......@@ -559,9 +565,7 @@ int XLALInitUserVars (UserInput_t *uvar)
uvar->deltaRad = 0.0;
uvar->rngMedBlock = 50;
uvar->numBins = 1;
uvar->pairListInputFilename = XLALStringDuplicate("");
uvar->pairListOutputFilename = XLALStringDuplicate("");
uvar->sftListOutputFilename = XLALStringDuplicate("");
/* default for reftime is in the middle */
uvar->refTime = 0.5*(uvar->startTime + uvar->endTime);
......
......@@ -31,7 +31,7 @@ int XLALGetDopplerShiftedFrequencyInfo
UINT4Vector *lowestBins, /**< Output list of bin indices */
REAL8Vector *kappaValues, /**< Output list of bin offsets */
REAL8Vector *signalPhases, /**< Output list of signal phases */
REAL8Vector *sincList, /**< Output list of sinc factors */
REAL8VectorSequence *sincList, /**< Output list of sinc factors */
UINT4 numBins, /**< Number of frequency bins to use */
PulsarDopplerParams *dopp, /**< Doppler parameters for signal */
SFTIndexList *sftIndices, /**< List of indices for SFTs */
......@@ -49,7 +49,7 @@ int XLALGetDopplerShiftedFrequencyInfo
|| shiftedFreqs->length !=numSFTs
|| lowestBins->length !=numSFTs
|| kappaValues->length !=numSFTs
|| sincList->length !=numSFTs ) {
|| sincList->length !=numSFTs*numBins ) {
XLALPrintError("Lengths of SFT-indexed lists don't match!");
XLAL_ERROR(XLAL_EBADLEN );
}
......@@ -103,9 +103,9 @@ int XLALGetDopplerShiftedFrequencyInfo
lowestBins->data[sftNum]
= ceil( fminusf0 * Tsft - 0.5*numBins );
kappaValues->data[sftNum] = lowestBins->data[sftNum] - fminusf0 * Tsft;
sincList->data[sftNum]=1;
for (UINT8 l=0; l < numBins; l++) {
sincList->data[sftNum] *= gsl_sf_sinc(kappaValues->data[sftNum]+l);
sincList->data[sftNum*numBins + l] = gsl_sf_sinc(kappaValues->data[sftNum]+l);
}
/* printf("f=%.7f, f0=%.7f, Tsft=%g, numbins=%d, lowestbin=%d, kappa=%g\n",
shiftedFreqs->data[sftNum],
......@@ -287,7 +287,7 @@ int XLALCalculatePulsarCrossCorrStatistic
REAL8Vector *signalPhases, /* Input: Phase of signal for each SFT */
UINT4Vector *lowestBins, /* Input: Bin index to start with for each SFT */
REAL8Vector *kappaValues, /* Input: Fractional offset of signal freq from best bin center */
REAL8Vector *sincList, /* Input: input the sinc factors*/
REAL8VectorSequence *sincList, /* Input: input the sinc factors*/
SFTPairIndexList *sftPairs, /* Input: flat list of SFT pairs */
SFTIndexList *sftIndices, /* Input: flat list of SFTs */
MultiSFTVector *inputSFTs, /* Input: SFT data */
......@@ -300,7 +300,7 @@ int XLALCalculatePulsarCrossCorrStatistic
if ( signalPhases->length !=numSFTs
|| lowestBins->length !=numSFTs
|| kappaValues->length !=numSFTs
|| sincList->length !=numSFTs ) {
|| sincList->length !=numSFTs * numBins ) {
XLALPrintError("Lengths of SFT-indexed lists don't match!");
XLAL_ERROR(XLAL_EBADLEN );
}
......@@ -372,7 +372,8 @@ int XLALCalculatePulsarCrossCorrStatistic
lowestBin2, numBins, lenDataArray2 );
for (UINT8 k=0; k < numBins; k++) {
COMPLEX16 data2 = dataArray2[lowestBins->data[sftNum2]+k];
REAL8 sincFactor = sincList->data[sftNum1] * sincList->data[sftNum2];
REAL8 sincFactor =1;
sincFactor = sincList->data[sftNum1 * numBins + k] * sincList->data[sftNum2 * numBins + k];
nume += creal ( GalphaCC * ccSign * sincFactor * conj(data1) * data2 ); /*multiWeights->data[detInd1]->data[sftNum1] * multiWeights->data[detInd2]->data[sftNum2] **/
REAL8 GalphaAmp = curlyGAmp->data[alpha] * sincFactor ; /** multiWeights->data[detInd1]->data[sftNum1] * multiWeights->data[detInd2]->data[sftNum2]*/
curlyGSqr += SQUARE( GalphaAmp );
......
......@@ -109,7 +109,7 @@ int XLALGetDopplerShiftedFrequencyInfo
UINT4Vector *lowestBins,
REAL8Vector *kappaValues,
REAL8Vector *signalPhases,
REAL8Vector *sincList,
REAL8VectorSequence *sincList,
UINT4 numBins,
PulsarDopplerParams *dopp,
SFTIndexList *sfts,
......@@ -153,7 +153,7 @@ int XLALCalculatePulsarCrossCorrStatistic
REAL8Vector *signalPhases,
UINT4Vector *lowestBins,
REAL8Vector *kappaValues,
REAL8Vector *sincList,
REAL8VectorSequence *sincList,
SFTPairIndexList *sftPairs,
SFTIndexList *sftIndices,
MultiSFTVector *inputSFTs,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment