53#include <lal/LALConfig.h>
54#include <lal/LALMalloc.h>
55#include <lal/LALStdio.h>
56#include <lal/LALError.h>
57#include <lal/LALStdlib.h>
58#include <lal/UserInput.h>
59#include <lal/SFTfileIO.h>
60#include <lal/LogPrintf.h>
61#include <lal/AVFactories.h>
62#include <lal/ComplexFFT.h>
63#include <lal/RealFFT.h>
64#include <lal/LALPulsarVCSInfo.h>
70#define MAXLINELENGTH 1024
132int main(
int argc,
char *argv[] );
152int main(
int argc,
char *argv[] )
180 if (
ReadInput( &uvar, &userParams, &Fstat, &exr ) ) {
195 if (
createComb( &userParams, &
template, &exr ) ) {
203 if (
ComputeCstat( &
template, &Fstat, &Cstat, &exr ) ) {
211 if (
OutputCstats( &uvar, &userParams, &Fstat, &Cstat, &exr ) ) {
340 if ( strncmp( &
line[0],
"%%", 2 ) == 0 ) {
345 strcpy( tempstring,
line );
346 strcat( Fstat->
comment, tempstring );
350 if ( strncmp( &
line[0],
"%", 1 ) != 0 && isdigit(
line[0] ) != 0 ) {
354 if ( fstat < 0 || isinf( fstat ) || isnan( fstat ) ) {
388 if ( ( ( strncmp(
line,
"%%", 1 ) ) != 0 ) && ( ( isdigit(
line[0] ) ) != 0 ) ) {
398 LogPrintf(
LOG_DEBUG,
"Acquired Fstats and search parameter information. File closed. \n" );
403 INT4 ufreq_bin, ufreqmax_bin, ufband, mm, dm, fbins, fstart_bin, fend_bin;
407 Porb = userParams->
orbitPeriod = uvar->orbitPeriod;
408 a0 = userParams->
orbitasini = uvar->orbitasini;
409 freq = userParams->
freq = uvar->Freq;
410 fband = userParams->
fband = uvar->FreqBand;
417 ufband = ufreqmax_bin - ufreq_bin + 1 ;
419 dm = floor( 0.5 + mm / ( Porb *
df ) );
420 fbins = ufband + 2 * dm;
421 fstart_bin = ufreq_bin - dm ;
423 fend_bin = fstart_bin + ufband + 2 * dm;
443 if ( uvar->tophat ) {
444 userParams->
unitspikes = floor( 0.5 + ( 2 * mm + 1 ) / ( Porb *
df ) );
457 for (
i = 0;
i < fbins;
i++ ) {
461 Fstat->
fmin = fstart;
496 for (
i = 0;
i < exr->
fbins;
i++ ) {
501 for (
i = 0;
i <= exr->
mm;
i++ ) {
507 for (
i = 1;
i <= exr->
mm;
i++ ) {
544 for (
i = 0;
i < exr->
fbins;
i++ ) {
549 for (
i = 0;
i <= exr->
dm;
i++ ) {
554 for (
i = 1;
i <= exr->
dm;
i++ ) {
560 tophat->
df = exr->
df;
564 LogPrintf(
LOG_DEBUG,
"%s: template with %d spikes created. halfwidth(dm) = %d bins\n", fn, tophat->
dof, exr->
dm );
587 REAL8FFTPlan *pfwd = NULL;
588 REAL8FFTPlan *prev = NULL;
610 for (
i = 0;
i < (
N / 2 + 1 );
i++ ) {
611 c_out->
data[
i] =
crect( ( creal( f_out->
data[
i] ) * creal( t_out->
data[
i] ) ) - ( cimag( f_out->
data[
i] ) * cimag( t_out->
data[
i] ) ), ( creal( f_out->
data[
i] ) * cimag( t_out->
data[
i] ) ) + ( cimag( f_out->
data[
i] ) * creal( t_out->
data[
i] ) ) );
624 for (
i = 0;
i < exr->
cbins;
i++ ) {
629 Cstat->
dof = Fstat->
dof *
template->dof;
631 Cstat->
df = Fstat->
df;
652 FILE *Cstat_out = NULL;
657 if ( ( Cstat_out = fopen( uvar->outputCstat,
"wb" ) ) == NULL ) {
668 fprintf( Cstat_out,
"%%%% *********************************************************************** \n" );
669 fprintf( Cstat_out,
"%%%% *************** Fstat Header ****************** \n %s", Fstat->
comment );
670 fprintf( Cstat_out,
"%%%% *********************************************************************** \n" );
671 fprintf( Cstat_out,
"%%%% *************** Cstat Header ****************** \n" );
674 fprintf( Cstat_out,
"%%%% %s\n%%%% cmdline: %s\n",
"$Id$", Cstat->
comment );
677 fprintf( Cstat_out,
"%%%% input: f0 = %f,\t asini = %lf, Porb = %lf,\t user fmin = %f,\n", userParams->
f0, userParams->
orbitasini, userParams->
orbitPeriod, userParams->
freq );
678 fprintf( Cstat_out,
"%%%% Fstat params: fmin = %lf \t df = %2.16e \t fbins = %d \t dof = %d \n", Fstat->
fmin, Fstat->
df, Fstat->
fvect->
length, Fstat->
dof );
679 fprintf( Cstat_out,
"%%%% Cstat params: fmin = %lf \t df = %2.16e \t cbins = %d \t dof = %d \n", Cstat->
fmin, Cstat->
df, Cstat->
fvect->
length, Cstat->
dof );
680 fprintf( Cstat_out,
"%%%% \n%%%% i \t frequency \t\t Fstat \t\t Cstat \n " );
683 for (
i = 0;
i < exr->
cbins;
i++ ) {
686 fprintf( Cstat_out,
"%% Done" );
int main(int argc, char *argv[])
MAIN function of sb_search code.
int ComputeCstat(VectorStruct *template, VectorStruct *Fstat, VectorStruct *Cstat, ExRegion *exr)
ComputeCstat function uses comb and Fstat structures to calculate the Cstat.
int createTopHat(ParamStruct *userParams, VectorStruct *tophat, ExRegion *exr)
createTopHat function use userParams to create tophat template if tophat flag is raised
int OutputCstats(UserInput_t *uvar, ParamStruct *userParams, VectorStruct *Fstat, VectorStruct *Cstat, ExRegion *exr)
int createComb(ParamStruct *userParams, VectorStruct *comb, ExRegion *exr)
createComb function use userParams to create comb template
int vrbflg
defined in lal/lib/std/LALError.c
int ReadInput(UserInput_t *uvar, ParamStruct *userParams, VectorStruct *Fstat, ExRegion *exr)
ReadInput function reads user input and Fstat file and assigns parameter values and Fstat array.
int initUserVars(int argc, char *argv[], UserInput_t *uvar)
initUserVars function Register "user-variables" specified from cmd-line and/or config-file.
int checkUserInputConsistency(const UserInput_t *uvar)
Some general consistency-checks on user-input.
const char * va(const char *format,...)
#define __func__
log an I/O error, i.e.
void LALCheckMemoryLeaks(void)
const LALVCSInfoList lalPulsarVCSInfoList
NULL-terminated list of VCS and build information for LALPulsar and its dependencies
static double double delta
#define XLAL_INIT_DECL(var,...)
void * XLALCalloc(size_t m, size_t n)
void * XLALRealloc(void *p, size_t n)
void LogPrintf(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
int XLALREAL8ForwardFFT(COMPLEX16Vector *output, const REAL8Vector *input, const REAL8FFTPlan *plan)
int XLALREAL8ReverseFFT(REAL8Vector *output, const COMPLEX16Vector *input, const REAL8FFTPlan *plan)
void XLALDestroyREAL8FFTPlan(REAL8FFTPlan *plan)
REAL8FFTPlan * XLALCreateREAL8FFTPlan(UINT4 size, int fwdflg, int measurelvl)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
COMPLEX16Vector * XLALCreateCOMPLEX16Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
void XLALDestroyCOMPLEX16Vector(COMPLEX16Vector *vector)
A structure for information on the exclusion region needed to avoid edge effects in calculation of Cs...
INT4 dm
number of bins spanned by mm
INT4 mm
number of sidebands on either side of central spike
INT4 fbins
number of bins in Fstat
INT4 cbins
number of bins in Cstat
A structure for template parameters.
REAL8 fband
user defined frequency band
REAL8 orbitasini
light travel time across semi-major axis of source
REAL8 freq
user defined start frequency
REAL8 f0
search frequency, centre of user band, used to determine width of template
REAL8 orbitPeriod
orbital period of source
INT4 unitspikes
number of unit spikes in template
A structure for frequency series.
CHAR * comment
comment field
REAL8Vector * fvect
frequency series of data, REAL8Vector has components data and length
REAL8 df
frequency separation in Fseries
INT4 dof
degrees of freedom of detection statistic represented by frequency series
REAL8 fmin
start frequency of data in Fseries