52 CHAR *injectfile = NULL, *snrfile = NULL;
53 ProcessParamsTable *
ppt;
54 ProcessParamsTable *commandLine = runState->
commandLine;
72 CHAR *dotloc = strrchr( snrfile,
'.' );
73 CHAR *slashloc = strrchr( snrfile,
'/' );
74 if ( dotloc != NULL ) {
75 if ( slashloc != NULL ) {
76 if ( slashloc < dotloc ) {
85 if ( ( fpsnr = fopen( snrfile,
"w" ) ) == NULL ) {
95 if ( fopen( injectfile,
"r" ) == NULL ) {
148 if ( freqs->
length > freqnum ) {
150 }
else if ( freqs->
length < freqnum ) {
156 freqsnew->
data[
i] = 0.;
164 for (
UINT4 i = 0;
i < freqnum;
i++ ) {
165 freqsnew->
data[
i] = 0.;
172 for (
UINT4 i = 0;
i < freqnum;
i++ ) {
174 snprintf( varname,
sizeof( varname ),
"F%u_FIXED",
i );
176 deltafreqs->
data[
i] = freqs->
data[
i] - f0fixed;
187 snrscale = atof(
ppt->value );
192 INT4 varyphase = 1, varyskypos = 1, varybinary = 1;
193 while ( ifo_model ) {
210 ifo_model = ifo_model->
next;
217 char *injection_model = NULL;
218 ProcessParamsTable *nonGR_injection;
221 if ( nonGR_injection ) {
224 if ( !nonGR_search ) {
227 while ( ifo_model ) {
229 ifo_model = ifo_model->
next;
239 if ( *injection_model !=
'\0' ) {
245 while ( ifo_model ) {
247 ifo_model = ifo_model->
next;
257 fprintf( fpsnr,
"# Injected SNR\n" );
267 snrmulti +=
SQUARE( snrval );
270 if ( snrscale == 0. ) {
275 ifo_model = ifo_model->
next;
281 snrmulti = sqrt( snrmulti );
284 if ( snrscale == 0. ) {
286 fprintf( fpsnr,
"Coherent\t%le\n", snrmulti );
290 snrscale /= snrmulti;
317 snrmulti +=
SQUARE( snrval );
319 fprintf( fpsnr,
"%s\t%.3lf\t%le\t%le\n",
data->name, freqFactors->
data[ndats % (
INT4 )freqFactors->
length], snrscale, snrval );
322 ifo_model = ifo_model->
next;
327 snrmulti = sqrt( snrmulti );
331 fprintf( fpsnr,
"Coherent\t%le\n", snrmulti );
343 FILE *
fp = NULL, *fpso = NULL;
351 CHAR *signalonly = NULL;
362 sf = sprintf( suffix,
"_%.1lf", freqFactors->
data[ndats % (
INT4 )freqFactors->
length] );
365 if ( (
fp = fopen(
outfile,
"w" ) ) == NULL || !sf ) {
366 fprintf( stderr,
"Non-fatal error... unable to open file %s to output injection\n",
outfile );
372 if ( ( fpso = fopen( signalonly,
"w" ) ) == NULL ) {
373 fprintf( stderr,
"Non-fatal error... unable to open file %s to output injection\n", signalonly );
379 for (
i = 0;
i < length;
i++ ) {
383 if (
fp != NULL && fpso != NULL ) {
386 creal(
data->compTimeData->data->data[
i] ), cimag(
data->compTimeData->data->data[
i] ) );
397 if ( fpso != NULL ) {
407 ifo_model = ifo_model->
next;
413 if ( nonGR_search ) {
414 if ( !nonGR_injection ) {
416 while ( ifo_model ) {
418 ifo_model = ifo_model->
next;
423 while ( ifo_model ) {
425 ifo_model = ifo_model->
next;
430 UINT4 outputchunks = 0, chunkMin = 0, chunkMax = 0;
438 while ( ifo_model ) {
467 ifo_model = ifo_model->
next;
505 REAL8 snrval = 0., chunkLength = 0;
507 INT4 i = 0,
j = 0, length = 0, cl = 0;
509 INT4 chunkMin = 0,
count = 0, varyphase = 0, nonGR = 0, roq = 0;
515 REAL8Vector *sumP = NULL, *sumC = NULL, *sumX = NULL, *sumY = NULL, *sumB = NULL, *sumL = NULL;
516 REAL8Vector *sumPC = NULL, *sumPX = NULL, *sumPY = NULL, *sumPB = NULL, *sumPL = NULL;
517 REAL8Vector *sumCX = NULL, *sumCY = NULL, *sumCB = NULL, *sumCL = NULL;
518 REAL8Vector *sumXY = NULL, *sumXB = NULL, *sumXL = NULL;
532 if ( !varyphase && !roq ) {
561 length =
data->compTimeData->data->length;
563 for (
i = 0;
i < length;
i += (
INT4 )chunkLength ) {
564 REAL8 snrcRe = 0., snrcIm = 0.;
569 if ( chunkLength < chunkMin ) {
574 cl =
i + (
INT4 )chunkLength;
577 if ( varyphase || roq ) {
578 for (
j =
i ;
j < cl ;
j++ ) {
588 snrcRe += sumP->
data[
count] * ( creal( Mp ) * creal( Mp ) + cimag( Mp ) * cimag( Mp ) ) +
589 sumC->data[
count] * ( creal( Mc ) * creal( Mc ) + cimag( Mc ) * cimag( Mc ) ) +
590 2.*sumPC->
data[
count] * ( creal( Mp ) * creal( Mc ) + cimag( Mp ) * cimag( Mc ) );
601 snrcRe += sumX->data[
count] * ( creal( Mx ) * creal( Mx ) + cimag( Mx ) * cimag( Mx ) ) +
602 sumY->data[
count] * ( creal( My ) * creal( My ) + cimag( My ) * cimag( My ) ) +
603 sumB->data[
count] * ( creal( Mb ) * creal( Mb ) + cimag( Mb ) * cimag( Mb ) ) +
604 sumL->data[
count] * ( creal( Ml ) * creal( Ml ) + cimag( Ml ) * cimag( Ml ) ) +
605 2.*( sumPX->data[
count] * ( creal( Mp ) * creal( Mx ) + cimag( Mp ) * cimag( Mx ) ) +
606 sumPY->data[
count] * ( creal( Mp ) * creal( My ) + cimag( Mp ) * cimag( My ) ) +
607 sumPB->data[
count] * ( creal( Mp ) * creal( Mb ) + cimag( Mp ) * cimag( Mb ) ) +
608 sumPL->data[
count] * ( creal( Mp ) * creal( Ml ) + cimag( Mp ) * cimag( Ml ) ) +
609 sumCX->
data[
count] * ( creal( Mc ) * creal( Mx ) + cimag( Mc ) * cimag( Mx ) ) +
610 sumCY->data[
count] * ( creal( Mc ) * creal( My ) + cimag( Mc ) * cimag( My ) ) +
611 sumCB->data[
count] * ( creal( Mc ) * creal( Mb ) + cimag( Mc ) * cimag( Mb ) ) +
612 sumCL->data[
count] * ( creal( Mc ) * creal( Ml ) + cimag( Mc ) * cimag( Ml ) ) +
613 sumXY->
data[
count] * ( creal( Mx ) * creal( My ) + cimag( Mx ) * cimag( My ) ) +
614 sumXB->data[
count] * ( creal( Mx ) * creal( Mb ) + cimag( Mx ) * cimag( Mb ) ) +
615 sumXL->data[
count] * ( creal( Mx ) * creal( Ml ) + cimag( Mx ) * cimag( Ml ) ) +
616 sumYB->
data[
count] * ( creal( My ) * creal( Mb ) + cimag( My ) * cimag( Mb ) ) +
617 sumYL->data[
count] * ( creal( My ) * creal( Ml ) + cimag( My ) * cimag( Ml ) ) +
618 sumBL->
data[
count] * ( creal( Mb ) * creal( Ml ) + cimag( Mb ) * cimag( Ml ) ) );
623 snrval += ( snrcRe + snrcIm );
628 snrval = sqrt( snrval );
655 CHAR *snrfile = NULL;
658 ProcessParamsTable *
ppt;
659 ProcessParamsTable *commandLine = runState->
commandLine;
674 while ( ifo_model ) {
709 UINT4 varyphasetmp = 1;
713 ifo_model = ifo_model->
next;
724 fprintf( stderr,
"Error... maximum log likelihood problem!\n" );
731 fprintf( stderr,
"WARNING... maximum likelihood using ROQ is greater than 0.1%% different that the full likelihood calculation.\n" );
745 CHAR *dotloc = strrchr( snrfile,
'.' );
746 CHAR *slashloc = strrchr( snrfile,
'/' );
747 if ( dotloc != NULL ) {
748 if ( slashloc != NULL ) {
749 if ( slashloc < dotloc ) {
759 if ( ( fpsnr = fopen( snrfile,
"a" ) ) == NULL ) {
760 fprintf( stderr,
"Error... cannot open output SNR file!\n" );
772 fprintf( fpsnr,
"# Recovered SNR\n" );
793 snrmulti +=
SQUARE( snrval );
801 ifo_model = ifo_model->
next;
808 fprintf( fpsnr,
"Coherent\t%le\n", sqrt( snrmulti ) );
const REAL8Vector * PulsarGetREAL8VectorParam(const PulsarParameters *pars, const CHAR *name)
Return a REAL8Vector parameter.
REAL8 PulsarGetREAL8ParamOrZero(const PulsarParameters *pars, const CHAR *name)
Return a REAL8 parameter if it exists, otherwise return zero.
int PulsarCheckParam(const PulsarParameters *pars, const CHAR *name)
Check for the existence of the parameter name in the PulsarParameters structure.
PulsarParameters * XLALReadTEMPOParFile(const CHAR *pulsarAndPath)
Read in the parameters from a TEMPO(2) parameter file into a PulsarParameters structure.
void PulsarAddParam(PulsarParameters *pars, const CHAR *name, void *value, PulsarParamType type)
Add a parameter and value to the PulsarParameters structure.
REAL8 PulsarGetREAL8Param(const PulsarParameters *pars, const CHAR *name)
Return a REAL8 parameter.
void PulsarRemoveParam(PulsarParameters *pars, const CHAR *name)
Remove a given parameter from a PulsarParameters structure.
void PulsarFreeParams(PulsarParameters *pars)
Function to free memory from pulsar parameters.
void PulsarAddREAL8VectorParam(PulsarParameters *pars, const CHAR *name, const REAL8Vector *value)
Add a REAL8Vector parameter to the PulsarParameters structure.
REAL8 PulsarGetREAL8VectorParamIndividual(const PulsarParameters *pars, const CHAR *name)
Return an individual REAL8 value from a REAL8Vector parameter.
LIGOTimeGPSVector * timestamps
UINT4 LALInferenceGetUINT4Variable(LALInferenceVariables *vars, const char *name)
void LALInferenceAddVariable(LALInferenceVariables *vars, const char *name, const void *value, LALInferenceVariableType type, LALInferenceParamVaryType vary)
REAL8 LALInferenceGetREAL8Variable(LALInferenceVariables *vars, const char *name)
void LALInferenceRemoveVariable(LALInferenceVariables *vars, const char *name)
void LALInferenceCopyVariables(LALInferenceVariables *origin, LALInferenceVariables *target)
void * LALInferenceGetVariable(const LALInferenceVariables *vars, const char *name)
INT4 LALInferenceGetINT4Variable(LALInferenceVariables *vars, const char *name)
ProcessParamsTable * LALInferenceGetProcParamVal(ProcessParamsTable *procparams, const char *name)
void LALInferenceClearVariables(LALInferenceVariables *vars)
int LALInferenceCheckVariable(LALInferenceVariables *vars, const char *name)
LALINFERENCE_REAL8Vector_t
LALINFERENCE_UINT4Vector_t
void * XLALCalloc(size_t m, size_t n)
char char * XLALStringDuplicate(const char *s)
int char * XLALStringAppend(char *s, const char *append)
void XLALDestroyTimestampVector(LIGOTimeGPSVector *vect)
De-allocate a LIGOTimeGPSVector.
COORDINATESYSTEM_EQUATORIAL
COMPLEX16TimeSeries * XLALResizeCOMPLEX16TimeSeries(COMPLEX16TimeSeries *series, int first, size_t length)
REAL8Vector * XLALCreateREAL8Vector(UINT4 length)
void XLALDestroyREAL8Vector(REAL8Vector *vector)
#define XLAL_ERROR_VOID(...)
REAL8 XLALGPSGetREAL8(const LIGOTimeGPS *epoch)
void sum_data(LALInferenceRunState *runState)
Calculates the sum of the square of the data and model terms.
void setup_lookup_tables(LALInferenceRunState *runState, LALSource *source)
Sets the time angle antenna response lookup table.
REAL8 calculate_time_domain_snr(LALInferenceIFOData *data, LALInferenceIFOModel *ifo_model)
Calculates the optimal matched filter signal-to-noise ratio for a given signal.
void inject_signal(LALInferenceRunState *runState)
Inject a simulated signal into the data.
void get_loudest_snr(LALInferenceRunState *runState)
Get the signal-to-noise ratio of the maximum likelihood signal.
Header file for the signal injection functions for the parameter estimation code for known pulsar sea...
void pulsar_model(PulsarParameters *params, LALInferenceIFOModel *ifo)
Generate the model of the neutron star signal.
void invert_source_params(PulsarParameters *params)
Convert sources parameters into amplitude and phase notation parameters.
void set_nonGR_model_parameters(PulsarParameters *pars, char *nonGRmodel)
Set amplitude parameters for specific non-GR models.
#define IFO_XTRA_DATA(ifo)
void compute_variance(LALInferenceIFOData *data, LALInferenceIFOModel *model)
Compute the noise variance for each data segment.
UINT4Vector * chop_n_merge(LALInferenceIFOData *data, UINT4 chunkMin, UINT4 chunkMax, UINT4 outputchunks)
Chops and remerges data into stationary segments.
struct tagLALInferenceIFOModel * next
LALInferenceVariables * params
COMPLEX16TimeSeries * compTimeSignal
LALInferenceIFOModel * ifo
ProcessParamsTable * commandLine
LALInferenceVariables * algorithmParams
struct tagLALInferenceIFOData * data
LALInferenceThreadState * threads
LALInferenceVariables ** livePoints
LALInferenceLikelihoodFunction likelihood
LALInferenceVariables * currentParams
LALInferenceModel * model
SkyPosition equatorialCoords
A vector of 'timestamps' of type LIGOTimeGPS.
The PulsarParameters structure to contain a set of pulsar parameters.